information-system-model-do.../src/main/java/org/gcube/informationsystem/utils/documentation/model/entities/ResourceDocumentationGenera...

48 lines
1.9 KiB
Java
Raw Normal View History

2023-01-19 18:37:12 +01:00
package org.gcube.informationsystem.utils.documentation.model.entities;
2023-01-20 17:49:41 +01:00
import java.util.Set;
2023-01-20 16:44:56 +01:00
import org.gcube.informationsystem.base.reference.AccessType;
2023-01-20 10:27:07 +01:00
import org.gcube.informationsystem.types.reference.Type;
2023-01-20 16:44:56 +01:00
import org.gcube.informationsystem.types.reference.entities.ResourceType;
2023-01-20 17:49:41 +01:00
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
2023-01-22 19:44:32 +01:00
import org.gcube.informationsystem.utils.documentation.knowledge.UsageKnowledge;
2023-01-19 18:37:12 +01:00
import org.gcube.informationsystem.utils.documentation.rst.table.Table;
/**
* @author Luca Frosini (ISTI - CNR)
*/
2023-01-20 10:27:07 +01:00
public class ResourceDocumentationGenerator extends EntityDocumentationGenerator {
2023-01-19 18:37:12 +01:00
2023-01-24 16:54:00 +01:00
public static final String FACETS_TABLE_HEADING = "**Facets**";
public static final String RESOURCE_RELATIONS_TABLE_HEADING = "**Resource Relations**";
public static final String NO_SPECIFIC_FACETS = "No specific facets usage defined for this type.";
public static final String NO_SPECIFIC_RESOURCE_RELATIONS = "No specific Resource relations defined for this type.";
2023-01-20 10:27:07 +01:00
public ResourceDocumentationGenerator(Type type) {
2023-01-20 16:44:56 +01:00
super(type,AccessType.RESOURCE);
2023-01-22 19:44:32 +01:00
int level = 1;
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(getSourceTargetHeadingRow());
2023-01-24 16:54:00 +01:00
table.appendRow(getRowCellSpan(FACETS_TABLE_HEADING, requiredNumberOfColumns));
2023-01-20 16:44:56 +01:00
ResourceType resourceType = (ResourceType) type;
2023-01-22 19:44:32 +01:00
UsageKnowledge fk = UsageKnowledge.getFacetKnowledge();
2023-01-20 17:49:41 +01:00
Set<LinkedEntity> facets = fk.getUsage(resourceType.getName());
2023-01-24 16:54:00 +01:00
addLinkedEntities(table, facets, NO_SPECIFIC_FACETS);
table.appendRow(getRowCellSpan(RESOURCE_RELATIONS_TABLE_HEADING, requiredNumberOfColumns));
2023-01-22 19:44:32 +01:00
UsageKnowledge rk = UsageKnowledge.getResourceKnowledge();
2023-01-20 17:49:41 +01:00
Set<LinkedEntity> resources = rk.getUsage(resourceType.getName());
2023-01-24 16:54:00 +01:00
addLinkedEntities(table, resources, NO_SPECIFIC_RESOURCE_RELATIONS);
2023-01-19 18:37:12 +01:00
return table;
}
2023-01-24 18:17:47 +01:00
2023-01-19 18:37:12 +01:00
}