use of com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO in project geoprism-registry by terraframe.
the class UndirectedGraphType method create.
@Transaction
public static UndirectedGraphType create(String code, LocalizedValue label, LocalizedValue description) {
RoleDAO maintainer = RoleDAO.findRole(RegistryConstants.REGISTRY_MAINTAINER_ROLE).getBusinessDAO();
RoleDAO consumer = RoleDAO.findRole(RegistryConstants.API_CONSUMER_ROLE).getBusinessDAO();
RoleDAO contributor = RoleDAO.findRole(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE).getBusinessDAO();
try {
MdVertexDAOIF mdBusGeoEntity = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdEdgeDAO mdEdgeDAO = MdEdgeDAO.newInstance();
mdEdgeDAO.setValue(MdEdgeInfo.PACKAGE, RegistryConstants.UNDIRECTED_GRAPH_PACKAGE);
mdEdgeDAO.setValue(MdEdgeInfo.NAME, code);
mdEdgeDAO.setValue(MdEdgeInfo.PARENT_MD_VERTEX, mdBusGeoEntity.getOid());
mdEdgeDAO.setValue(MdEdgeInfo.CHILD_MD_VERTEX, mdBusGeoEntity.getOid());
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DISPLAY_LABEL, label);
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DESCRIPTION, description);
mdEdgeDAO.setValue(MdEdgeInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.FALSE);
mdEdgeDAO.apply();
MdAttributeDateTimeDAO startDate = MdAttributeDateTimeDAO.newInstance();
startDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.START_DATE);
startDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
startDate.apply();
MdAttributeDateTimeDAO endDate = MdAttributeDateTimeDAO.newInstance();
endDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.END_DATE);
endDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
endDate.apply();
ServerHierarchyTypeBuilder permissionBuilder = new ServerHierarchyTypeBuilder();
permissionBuilder.grantWritePermissionsOnMdTermRel(mdEdgeDAO);
permissionBuilder.grantWritePermissionsOnMdTermRel(maintainer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(consumer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(contributor, mdEdgeDAO);
UndirectedGraphType graphType = new UndirectedGraphType();
graphType.setCode(code);
graphType.setMdEdgeId(mdEdgeDAO.getOid());
LocalizedValueConverter.populate(graphType.getDisplayLabel(), label);
LocalizedValueConverter.populate(graphType.getDescription(), description);
graphType.apply();
return graphType;
} catch (DuplicateDataException ex) {
DuplicateHierarchyTypeException ex2 = new DuplicateHierarchyTypeException();
ex2.setDuplicateValue(code);
throw ex2;
}
}
use of com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO in project geoprism-registry by terraframe.
the class AddWritePermissions method reassignPermissions.
private void reassignPermissions(ServerHierarchyType hierarchyType) {
RoleDAO maintainer = RoleDAO.findRole(RegistryConstants.REGISTRY_MAINTAINER_ROLE).getBusinessDAO();
RoleDAO consumer = RoleDAO.findRole(RegistryConstants.API_CONSUMER_ROLE).getBusinessDAO();
RoleDAO contributor = RoleDAO.findRole(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE).getBusinessDAO();
InitializationStrategyIF strategy = new InitializationStrategyIF() {
@Override
public void preApply(MdBusinessDAO mdBusiness) {
mdBusiness.setValue(MdBusinessInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
}
@Override
public void postApply(MdBusinessDAO mdBusiness) {
RoleDAO adminRole = RoleDAO.findRole(DefaultConfiguration.ADMIN).getBusinessDAO();
adminRole.grantPermission(Operation.READ, mdBusiness.getOid());
adminRole.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.CREATE, mdBusiness.getOid());
adminRole.grantPermission(Operation.DELETE, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.CREATE, mdBusiness.getOid());
maintainer.grantPermission(Operation.DELETE, mdBusiness.getOid());
consumer.grantPermission(Operation.READ, mdBusiness.getOid());
consumer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
contributor.grantPermission(Operation.READ, mdBusiness.getOid());
contributor.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
}
};
String key = GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode() + RegistryConstants.UNIVERSAL_RELATIONSHIP_POST;
if (hierarchyType.getCode().equals("LocatedIn")) {
key = GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode();
}
MdTermRelationship mdTermRelUniversal = MdTermRelationship.getByKey(key);
this.grantWritePermissionsOnMdTermRel(mdTermRelUniversal);
this.grantWritePermissionsOnMdTermRel(maintainer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(consumer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(contributor, mdTermRelUniversal);
Universal.getStrategy().initialize(mdTermRelUniversal.definesType(), strategy);
MdTermRelationship mdTermRelGeoEntity = MdTermRelationship.getByKey(GISConstants.GEO_PACKAGE + "." + hierarchyType.getCode());
this.grantWritePermissionsOnMdTermRel(mdTermRelGeoEntity);
this.grantWritePermissionsOnMdTermRel(maintainer, mdTermRelGeoEntity);
this.grantReadPermissionsOnMdTermRel(consumer, mdTermRelGeoEntity);
this.grantReadPermissionsOnMdTermRel(contributor, mdTermRelGeoEntity);
MdEdgeDAO mdEdge = (MdEdgeDAO) MdEdgeDAO.getMdEdgeDAO(RegistryConstants.UNIVERSAL_GRAPH_PACKAGE + "." + hierarchyType.getCode());
this.grantWritePermissionsOnMdTermRel(mdEdge);
this.grantWritePermissionsOnMdTermRel(maintainer, mdEdge);
this.grantReadPermissionsOnMdTermRel(consumer, mdEdge);
this.grantReadPermissionsOnMdTermRel(contributor, mdEdge);
logger.info("Updated permissions for HierarchyType [" + hierarchyType.getCode() + "]. ");
}
use of com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphType method create.
@Transaction
public static DirectedAcyclicGraphType create(String code, LocalizedValue label, LocalizedValue description) {
RoleDAO maintainer = RoleDAO.findRole(RegistryConstants.REGISTRY_MAINTAINER_ROLE).getBusinessDAO();
RoleDAO consumer = RoleDAO.findRole(RegistryConstants.API_CONSUMER_ROLE).getBusinessDAO();
RoleDAO contributor = RoleDAO.findRole(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE).getBusinessDAO();
try {
MdVertexDAOIF mdBusGeoEntity = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdEdgeDAO mdEdgeDAO = MdEdgeDAO.newInstance();
mdEdgeDAO.setValue(MdEdgeInfo.PACKAGE, RegistryConstants.DAG_PACKAGE);
mdEdgeDAO.setValue(MdEdgeInfo.NAME, code);
mdEdgeDAO.setValue(MdEdgeInfo.PARENT_MD_VERTEX, mdBusGeoEntity.getOid());
mdEdgeDAO.setValue(MdEdgeInfo.CHILD_MD_VERTEX, mdBusGeoEntity.getOid());
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DISPLAY_LABEL, label);
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DESCRIPTION, description);
mdEdgeDAO.setValue(MdEdgeInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.FALSE);
mdEdgeDAO.apply();
MdAttributeDateTimeDAO startDate = MdAttributeDateTimeDAO.newInstance();
startDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.START_DATE);
startDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
startDate.apply();
MdAttributeDateTimeDAO endDate = MdAttributeDateTimeDAO.newInstance();
endDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.END_DATE);
endDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
endDate.apply();
ServerHierarchyTypeBuilder permissionBuilder = new ServerHierarchyTypeBuilder();
permissionBuilder.grantWritePermissionsOnMdTermRel(mdEdgeDAO);
permissionBuilder.grantWritePermissionsOnMdTermRel(maintainer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(consumer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(contributor, mdEdgeDAO);
DirectedAcyclicGraphType graphType = new DirectedAcyclicGraphType();
graphType.setCode(code);
graphType.setMdEdgeId(mdEdgeDAO.getOid());
LocalizedValueConverter.populate(graphType.getDisplayLabel(), label);
LocalizedValueConverter.populate(graphType.getDescription(), description);
graphType.apply();
return graphType;
} catch (DuplicateDataException ex) {
DuplicateHierarchyTypeException ex2 = new DuplicateHierarchyTypeException();
ex2.setDuplicateValue(code);
throw ex2;
}
}
use of com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO in project geoprism-registry by terraframe.
the class ServerHierarchyTypeBuilder method createMdEdge.
/**
* It creates an {@link MdTermRelationship} to model the relationship between
* {@link GeoEntity}s.
*
* Needs to occur in a transaction.
*
* @param hierarchyType
* @return
*/
public MdEdge createMdEdge(HierarchyType hierarchyType) {
MdVertexDAOIF mdBusGeoEntity = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdEdgeDAO mdEdgeDAO = MdEdgeDAO.newInstance();
mdEdgeDAO.setValue(MdEdgeInfo.PACKAGE, RegistryConstants.UNIVERSAL_GRAPH_PACKAGE);
mdEdgeDAO.setValue(MdEdgeInfo.NAME, hierarchyType.getCode());
mdEdgeDAO.setValue(MdEdgeInfo.PARENT_MD_VERTEX, mdBusGeoEntity.getOid());
mdEdgeDAO.setValue(MdEdgeInfo.CHILD_MD_VERTEX, mdBusGeoEntity.getOid());
populate(mdEdgeDAO, MdEdgeInfo.DISPLAY_LABEL, hierarchyType.getLabel());
populate(mdEdgeDAO, MdEdgeInfo.DESCRIPTION, hierarchyType.getDescription());
mdEdgeDAO.setValue(MdEdgeInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.FALSE);
mdEdgeDAO.apply();
MdAttributeDateTimeDAO startDate = MdAttributeDateTimeDAO.newInstance();
startDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.START_DATE);
startDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
startDate.apply();
MdAttributeDateTimeDAO endDate = MdAttributeDateTimeDAO.newInstance();
endDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.END_DATE);
endDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
endDate.apply();
return (MdEdge) BusinessFacade.get(mdEdgeDAO);
}
use of com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO in project geoprism-registry by terraframe.
the class SearchService method createSearchTable.
@Transaction
public void createSearchTable() {
String suffix = this.getSuffix();
String typeName = VERTEX_PREFIX + suffix;
MdVertexDAO mdVertex = MdVertexDAO.newInstance();
mdVertex.setValue(MdVertexInfo.PACKAGE, PACKAGE);
mdVertex.setValue(MdVertexInfo.NAME, typeName);
mdVertex.setValue(MdVertexInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
mdVertex.apply();
MdAttributeTextDAO label = MdAttributeTextDAO.newInstance();
label.setValue(MdAttributeTextInfo.NAME, LABEL);
label.setValue(MdAttributeTextInfo.DEFINING_MD_CLASS, mdVertex.getOid());
label.apply();
MdAttributeTextDAO code = MdAttributeTextDAO.newInstance();
code.setValue(MdAttributeTextInfo.NAME, CODE);
code.setValue(MdAttributeTextInfo.DEFINING_MD_CLASS, mdVertex.getOid());
code.setValue(MdAttributeTextInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
code.apply();
MdAttributeTextDAO vertexType = MdAttributeTextDAO.newInstance();
vertexType.setValue(MdAttributeTextInfo.NAME, VERTEX_TYPE);
vertexType.setValue(MdAttributeTextInfo.DEFINING_MD_CLASS, mdVertex.getOid());
vertexType.setValue(MdAttributeTextInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
vertexType.apply();
MdAttributeDateDAO startDate = MdAttributeDateDAO.newInstance();
startDate.setValue(MdAttributeTextInfo.NAME, START_DATE);
startDate.setValue(MdAttributeTextInfo.DEFINING_MD_CLASS, mdVertex.getOid());
startDate.setValue(MdAttributeTextInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
startDate.apply();
MdAttributeDateDAO endDate = MdAttributeDateDAO.newInstance();
endDate.setValue(MdAttributeTextInfo.NAME, END_DATE);
endDate.setValue(MdAttributeTextInfo.DEFINING_MD_CLASS, mdVertex.getOid());
endDate.setValue(MdAttributeTextInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
endDate.apply();
MdEdgeDAO mdEdge = MdEdgeDAO.newInstance();
mdEdge.setValue(MdVertexInfo.PACKAGE, PACKAGE);
mdEdge.setValue(MdVertexInfo.NAME, EDGE_PREFIX + suffix);
mdEdge.setValue(MdEdgeInfo.PARENT_MD_VERTEX, mdVertex.getOid());
mdEdge.setValue(MdEdgeInfo.CHILD_MD_VERTEX, MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS).getOid());
mdEdge.apply();
GraphDBService service = GraphDBService.getInstance();
GraphRequest dml = service.getGraphDBRequest();
GraphRequest ddl = service.getDDLGraphDBRequest();
String attributeName = label.getValue(MdAttributeTextInfo.NAME);
String className = mdVertex.getDBClassName();
String indexName = className + "." + attributeName;
String statement = "CREATE INDEX " + indexName + " ON " + className + "(" + attributeName + ") FULLTEXT ENGINE LUCENE";
GraphDDLCommandAction action = service.ddlCommand(dml, ddl, statement, new HashMap<String, Object>());
action.execute();
this.assignAllPermissions(Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE), mdVertex, mdEdge);
this.assignAllPermissions(Roles.findRoleByName(RegistryConstants.REGISTRY_ADMIN_ROLE), mdVertex, mdEdge);
this.assignAllPermissions(Roles.findRoleByName(RegistryConstants.REGISTRY_MAINTAINER_ROLE), mdVertex, mdEdge);
}
Aggregations