Search in sources :

Example 1 with MdAttributeDateTimeDAO

use of com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO 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;
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) DuplicateDataException(com.runwaysdk.dataaccess.DuplicateDataException) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) MdAttributeDateTimeDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with MdAttributeDateTimeDAO

use of com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO 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;
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) DuplicateDataException(com.runwaysdk.dataaccess.DuplicateDataException) RoleDAO(com.runwaysdk.business.rbac.RoleDAO) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) MdAttributeDateTimeDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with MdAttributeDateTimeDAO

use of com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO 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);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdEdge(com.runwaysdk.system.metadata.MdEdge) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) MdAttributeDateTimeDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO)

Aggregations

MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 MdAttributeDateTimeDAO (com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO)3 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)3 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)2 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)2 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)2 MdEdge (com.runwaysdk.system.metadata.MdEdge)1