Search in sources :

Example 1 with GraphDDLCommandAction

use of com.runwaysdk.dataaccess.graph.GraphDDLCommandAction in project geoprism-registry by terraframe.

the class CRAttributePatch method executeGraphDDLCommand.

public void executeGraphDDLCommand(String sql) {
    GraphDBService service = GraphDBService.getInstance();
    GraphRequest dml = service.getGraphDBRequest();
    GraphRequest ddl = service.getDDLGraphDBRequest();
    GraphDDLCommandAction action = service.ddlCommand(dml, ddl, sql, new HashMap<String, Object>());
    action.execute();
}
Also used : GraphRequest(com.runwaysdk.dataaccess.graph.GraphRequest) GraphDDLCommandAction(com.runwaysdk.dataaccess.graph.GraphDDLCommandAction) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphDBService(com.runwaysdk.dataaccess.graph.GraphDBService)

Example 2 with GraphDDLCommandAction

use of com.runwaysdk.dataaccess.graph.GraphDDLCommandAction 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);
}
Also used : MdAttributeTextDAO(com.runwaysdk.dataaccess.metadata.MdAttributeTextDAO) GraphRequest(com.runwaysdk.dataaccess.graph.GraphRequest) MdAttributeDateDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDateDAO) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) GraphDDLCommandAction(com.runwaysdk.dataaccess.graph.GraphDDLCommandAction) MdVertexDAO(com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphDBService(com.runwaysdk.dataaccess.graph.GraphDBService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

VertexObject (com.runwaysdk.business.graph.VertexObject)2 GraphDBService (com.runwaysdk.dataaccess.graph.GraphDBService)2 GraphDDLCommandAction (com.runwaysdk.dataaccess.graph.GraphDDLCommandAction)2 GraphRequest (com.runwaysdk.dataaccess.graph.GraphRequest)2 MdAttributeDateDAO (com.runwaysdk.dataaccess.metadata.MdAttributeDateDAO)1 MdAttributeTextDAO (com.runwaysdk.dataaccess.metadata.MdAttributeTextDAO)1 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)1 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1