2023-01-19 18:37:12 +01:00
|
|
|
package org.gcube.informationsystem.utils.documentation.model.properties;
|
|
|
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2023-01-20 16:44:56 +01:00
|
|
|
import org.gcube.informationsystem.base.reference.AccessType;
|
2023-01-19 18:37:12 +01:00
|
|
|
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
|
|
|
import org.gcube.informationsystem.types.TypeMapper;
|
2023-01-20 10:27:07 +01:00
|
|
|
import org.gcube.informationsystem.types.reference.Type;
|
2023-01-19 18:37:12 +01:00
|
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
2023-02-08 16:53:29 +01:00
|
|
|
import org.gcube.informationsystem.utils.documentation.model.Documentation;
|
2023-01-19 18:37:12 +01:00
|
|
|
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
2023-02-08 16:53:29 +01:00
|
|
|
public class PropertyDocumentation extends Documentation {
|
2023-01-19 18:37:12 +01:00
|
|
|
|
2023-02-08 16:53:29 +01:00
|
|
|
public PropertyDocumentation(Type type) {
|
2023-01-22 19:44:32 +01:00
|
|
|
super(type, AccessType.PROPERTY);
|
|
|
|
this.requiredNumberOfColumns = 4;
|
|
|
|
this.superClassToBeExcluded = TypeMapper.getType(PropertyElement.class);
|
|
|
|
int level = 0;
|
|
|
|
if(type.getName().compareTo(requiredType.getName())!=0) {
|
|
|
|
++level;
|
|
|
|
}
|
|
|
|
setLevel(level);
|
2023-01-19 18:37:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Table getTable() {
|
|
|
|
|
|
|
|
Table table = new Table();
|
2023-01-20 16:44:56 +01:00
|
|
|
table.appendRow(getPropertyFieldsHeadingRow());
|
2023-01-19 18:37:12 +01:00
|
|
|
Set<PropertyDefinition> properties = type.getProperties();
|
|
|
|
if(properties!=null && properties.size()>0) {
|
|
|
|
Set<PropertyDefinition> notMandatoryProperties = new HashSet<>();
|
|
|
|
for(PropertyDefinition propertyDefinition : properties) {
|
|
|
|
if(propertyDefinition.isMandatory()) {
|
|
|
|
/*
|
|
|
|
* Adding Mandatory properties first in the table
|
|
|
|
*/
|
|
|
|
table.appendRow(getPropertyRow(propertyDefinition));
|
|
|
|
}else {
|
|
|
|
notMandatoryProperties.add(propertyDefinition);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(PropertyDefinition propertyDefinition : notMandatoryProperties) {
|
|
|
|
table.appendRow(getPropertyRow(propertyDefinition));
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
table.appendRow(getNoPropertyRow());
|
|
|
|
}
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|