Search in sources :

Example 6 with ServerHierarchyTypeBuilder

use of net.geoprism.registry.conversion.ServerHierarchyTypeBuilder 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 7 with ServerHierarchyTypeBuilder

use of net.geoprism.registry.conversion.ServerHierarchyTypeBuilder in project geoprism-registry by terraframe.

the class XMLImporter method createServerHierarchyType.

private ServerHierarchyType createServerHierarchyType(Organization organization, Element elem) {
    String code = elem.getAttribute("code");
    LocalizedValue label = this.getLabel(elem);
    LocalizedValue description = this.getDescription(elem);
    String progress = elem.getAttribute("progress");
    String disclaimer = elem.getAttribute("disclaimer");
    String accessConstraints = elem.getAttribute("accessConstraints");
    String useConstraints = elem.getAttribute("useConstraints");
    String acknowledgement = elem.getAttribute("acknowledgement");
    HierarchyType type = new HierarchyType(code, label, description, organization.getCode());
    type.setProgress(progress);
    type.setDisclaimer(disclaimer);
    type.setAccessConstraints(accessConstraints);
    type.setUseConstraints(useConstraints);
    type.setAcknowledgement(acknowledgement);
    ServiceFactory.getHierarchyPermissionService().enforceCanCreate(organization.getCode());
    return new ServerHierarchyTypeBuilder().createHierarchyType(type);
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)

Aggregations

ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)7 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)5 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)3 RoleDAO (com.runwaysdk.business.rbac.RoleDAO)2 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)2 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)2 MdAttributeDateTimeDAO (com.runwaysdk.dataaccess.metadata.MdAttributeDateTimeDAO)2 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)2 QueryFactory (com.runwaysdk.query.QueryFactory)2 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)2 Authenticate (com.runwaysdk.business.rbac.Authenticate)1 Request (com.runwaysdk.session.Request)1 Universal (com.runwaysdk.system.gis.geo.Universal)1 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)1 Set (java.util.Set)1 HierarchicalRelationshipType (net.geoprism.registry.HierarchicalRelationshipType)1 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)1 InheritedHierarchyAnnotationQuery (net.geoprism.registry.InheritedHierarchyAnnotationQuery)1 Organization (net.geoprism.registry.Organization)1