Search in sources :

Example 1 with HierarchyType

use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.

the class GeoRegistryUtil method createHierarchyType.

@Authenticate
public static String createHierarchyType(String htJSON) {
    RegistryAdapter adapter = ServiceFactory.getAdapter();
    HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, adapter);
    ServiceFactory.getHierarchyPermissionService().enforceCanCreate(hierarchyType.getOrganizationCode());
    ServerHierarchyType sType = new ServerHierarchyTypeBuilder().createHierarchyType(hierarchyType);
    // The transaction did not error out, so it is safe to put into the cache.
    ServiceFactory.getMetadataCache().addHierarchyType(sType);
    return hierarchyType.getCode();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) RegistryAdapter(org.commongeoregistry.adapter.RegistryAdapter) Authenticate(com.runwaysdk.business.rbac.Authenticate)

Example 2 with HierarchyType

use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.

the class ListTypeVersion method createTable.

private TableMetadata createTable() {
    ListType masterlist = this.getListType();
    TableMetadata metadata = new TableMetadata();
    Locale currentLocale = Session.getCurrentLocale();
    String viewName = this.getTableName();
    // Create the MdTable
    MdBusinessDAO mdTableDAO = MdBusinessDAO.newInstance();
    mdTableDAO.setValue(MdTableInfo.NAME, viewName);
    mdTableDAO.setValue(MdTableInfo.PACKAGE, RegistryConstants.TABLE_PACKAGE);
    mdTableDAO.setStructValue(MdTableInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, masterlist.getDisplayLabel().getValue());
    mdTableDAO.setValue(MdTableInfo.TABLE_NAME, viewName);
    mdTableDAO.setValue(MdTableInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
    mdTableDAO.apply();
    MdBusiness mdBusiness = (MdBusiness) BusinessFacade.get(mdTableDAO);
    MdAttributeUUIDDAO mdAttributeOriginalId = MdAttributeUUIDDAO.newInstance();
    mdAttributeOriginalId.setValue(MdAttributeCharacterInfo.NAME, ORIGINAL_OID);
    mdAttributeOriginalId.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
    mdAttributeOriginalId.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Original oid");
    mdAttributeOriginalId.apply();
    metadata.setMdBusiness(mdBusiness);
    Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
    ServerGeoObjectType type = masterlist.getGeoObjectType();
    this.createMdAttributeFromAttributeType(mdBusiness, type.getGeometryType());
    Collection<AttributeType> attributeTypes = type.getAttributeMap().values();
    for (AttributeType attributeType : attributeTypes) {
        if (this.isValid(attributeType)) {
            createMdAttributeFromAttributeType(metadata, attributeType, type, locales);
        }
    }
    if ((type.getGeometryType().equals(GeometryType.MULTIPOINT) || type.getGeometryType().equals(GeometryType.POINT)) && masterlist.getIncludeLatLong()) {
        MdAttributeFloatDAO mdAttributeLatitude = MdAttributeFloatDAO.newInstance();
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.NAME, "latitude");
        mdAttributeLatitude.setStructValue(MdAttributeFloatInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Latitude");
        mdAttributeLatitude.setStructValue(MdAttributeFloatInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Latitude");
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.IMMUTABLE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.REJECT_ZERO, MdAttributeBooleanInfo.FALSE);
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.REJECT_NEGATIVE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.REJECT_POSITIVE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.LENGTH, "12");
        mdAttributeLatitude.setValue(MdAttributeFloatInfo.DECIMAL, "8");
        mdAttributeLatitude.apply();
        MdAttributeFloatDAO mdAttributeLongitude = MdAttributeFloatDAO.newInstance();
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.NAME, "longitude");
        mdAttributeLongitude.setStructValue(MdAttributeFloatInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Longitude");
        mdAttributeLongitude.setStructValue(MdAttributeFloatInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Longitude");
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.IMMUTABLE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.REJECT_ZERO, MdAttributeBooleanInfo.FALSE);
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.REJECT_NEGATIVE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.REJECT_POSITIVE, MdAttributeBooleanInfo.FALSE);
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.LENGTH, "12");
        mdAttributeLongitude.setValue(MdAttributeFloatInfo.DECIMAL, "8");
        mdAttributeLongitude.apply();
    }
    JsonArray hierarchies = masterlist.getHierarchiesAsJson();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        List<String> pCodes = masterlist.getParentCodes(hierarchy);
        if (pCodes.size() > 0) {
            String hCode = hierarchy.get("code").getAsString();
            ServerHierarchyType hierarchyType = ServiceFactory.getMetadataCache().getHierachyType(hCode).get();
            String hierarchyLabel = hierarchyType.getDisplayLabel().getValue(currentLocale);
            for (String pCode : pCodes) {
                ServerGeoObjectType got = ServerGeoObjectType.get(pCode);
                String typeLabel = got.getLabel().getValue(currentLocale);
                String attributeName = hCode.toLowerCase() + pCode.toLowerCase();
                String label = typeLabel + " (" + hierarchyLabel + ")";
                String codeDescription = LocalizationFacade.localize("masterlist.code.description");
                codeDescription = codeDescription.replaceAll("\\{typeLabel\\}", typeLabel);
                codeDescription = codeDescription.replaceAll("\\{hierarchyLabel\\}", hierarchyLabel);
                String labelDescription = LocalizationFacade.localize("masterlist.label.description");
                labelDescription = labelDescription.replaceAll("\\{typeLabel\\}", typeLabel);
                labelDescription = labelDescription.replaceAll("\\{hierarchyLabel\\}", hierarchyLabel);
                MdAttributeCharacterDAO mdAttributeCode = MdAttributeCharacterDAO.newInstance();
                mdAttributeCode.setValue(MdAttributeCharacterInfo.NAME, attributeName);
                mdAttributeCode.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
                mdAttributeCode.setValue(MdAttributeCharacterInfo.SIZE, "255");
                mdAttributeCode.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, label);
                mdAttributeCode.addItem(MdAttributeCharacterInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
                mdAttributeCode.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, codeDescription);
                mdAttributeCode.apply();
                MdAttributeCharacterDAO mdAttributeDefaultLocale = MdAttributeCharacterDAO.newInstance();
                mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.NAME, attributeName + DEFAULT_LOCALE);
                mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
                mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
                mdAttributeDefaultLocale.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, label + " (defaultLocale)");
                mdAttributeDefaultLocale.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, labelDescription.replaceAll("\\{locale\\}", "default"));
                mdAttributeDefaultLocale.apply();
                for (Locale locale : locales) {
                    MdAttributeCharacterDAO mdAttributeLocale = MdAttributeCharacterDAO.newInstance();
                    mdAttributeLocale.setValue(MdAttributeCharacterInfo.NAME, attributeName + locale.toString());
                    mdAttributeLocale.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
                    mdAttributeLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
                    mdAttributeLocale.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, label + " (" + locale + ")");
                    mdAttributeLocale.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, labelDescription.replaceAll("\\{locale\\}", locale.toString()));
                    mdAttributeLocale.apply();
                }
            }
        }
    }
    JsonArray subtypeHierarchies = masterlist.getSubtypeHierarchiesAsJson();
    for (int i = 0; i < subtypeHierarchies.size(); i++) {
        JsonObject hierarchy = subtypeHierarchies.get(i).getAsJsonObject();
        if (hierarchy.has("selected") && hierarchy.get("selected").getAsBoolean()) {
            String hCode = hierarchy.get("code").getAsString();
            HierarchyType hierarchyType = ServiceFactory.getAdapter().getMetadataCache().getHierachyType(hCode).get();
            String hierarchyLabel = hierarchyType.getLabel().getValue(currentLocale);
            String attributeName = hCode.toLowerCase();
            String codeDescription = LocalizationFacade.localize("masterlist.code.description");
            codeDescription = codeDescription.replaceAll("\\{typeLabel\\}", "");
            codeDescription = codeDescription.replaceAll("\\{hierarchyLabel\\}", hierarchyLabel);
            String labelDescription = LocalizationFacade.localize("masterlist.label.description");
            labelDescription = labelDescription.replaceAll("\\{typeLabel\\}", "");
            labelDescription = labelDescription.replaceAll("\\{hierarchyLabel\\}", hierarchyLabel);
            MdAttributeCharacterDAO mdAttributeCode = MdAttributeCharacterDAO.newInstance();
            mdAttributeCode.setValue(MdAttributeCharacterInfo.NAME, attributeName);
            mdAttributeCode.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
            mdAttributeCode.setValue(MdAttributeCharacterInfo.SIZE, "255");
            mdAttributeCode.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, hierarchyLabel);
            mdAttributeCode.addItem(MdAttributeCharacterInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
            mdAttributeCode.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, codeDescription);
            mdAttributeCode.apply();
            MdAttributeCharacterDAO mdAttributeDefaultLocale = MdAttributeCharacterDAO.newInstance();
            mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.NAME, attributeName + DEFAULT_LOCALE);
            mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
            mdAttributeDefaultLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
            mdAttributeDefaultLocale.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, hierarchyLabel + " (defaultLocale)");
            mdAttributeDefaultLocale.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, labelDescription.replaceAll("\\{locale\\}", "default"));
            mdAttributeDefaultLocale.apply();
            for (Locale locale : locales) {
                MdAttributeCharacterDAO mdAttributeLocale = MdAttributeCharacterDAO.newInstance();
                mdAttributeLocale.setValue(MdAttributeCharacterInfo.NAME, attributeName + locale.toString());
                mdAttributeLocale.setValue(MdAttributeCharacterInfo.DEFINING_MD_CLASS, mdTableDAO.getOid());
                mdAttributeLocale.setValue(MdAttributeCharacterInfo.SIZE, "255");
                mdAttributeLocale.setStructValue(MdAttributeCharacterInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, hierarchyLabel + " (" + locale + ")");
                mdAttributeLocale.setStructValue(MdAttributeCharacterInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, labelDescription.replaceAll("\\{locale\\}", locale.toString()));
                mdAttributeLocale.apply();
            }
        }
    }
    return metadata;
}
Also used : TableMetadata(net.geoprism.registry.masterlist.TableMetadata) Locale(java.util.Locale) MdAttributeFloatDAO(com.runwaysdk.dataaccess.metadata.MdAttributeFloatDAO) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MdAttributeUUIDDAO(com.runwaysdk.dataaccess.metadata.MdAttributeUUIDDAO) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point) JsonArray(com.google.gson.JsonArray) MdAttributeCharacterDAO(com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType)

Example 3 with HierarchyType

use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.

the class RemoveChildAction method getMessage.

@Override
protected String getMessage() {
    RegistryAdapter adapter = ServiceFactory.getAdapter();
    MetadataCache cache = adapter.getMetadataCache();
    ServerGeoObjectType parentType = ServerGeoObjectType.get(this.getParentTypeCode());
    ServerGeoObjectType childType = ServerGeoObjectType.get(this.getChildTypeCode());
    HierarchyType hierarchyType = cache.getHierachyType(this.getHierarchyTypeCode()).get();
    String message = LocalizationFacade.getFromBundles("change.request.email.remove.child");
    message = message.replaceAll("\\{0\\}", this.getChildId());
    message = message.replaceAll("\\{1\\}", childType.getLabel().getValue(Session.getCurrentLocale()));
    message = message.replaceAll("\\{2\\}", this.getParentId());
    message = message.replaceAll("\\{3\\}", parentType.getLabel().getValue(Session.getCurrentLocale()));
    message = message.replaceAll("\\{4\\}", hierarchyType.getLabel().getValue(Session.getCurrentLocale()));
    return message;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MetadataCache(org.commongeoregistry.adapter.metadata.MetadataCache) RegistryAdapter(org.commongeoregistry.adapter.RegistryAdapter)

Example 4 with HierarchyType

use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.

the class HierarchyController method setInheritedHierarchy.

/**
 * Modifies a hierarchy to inherit from another hierarchy at the given
 * GeoObjectType
 *
 * @param request
 *          Session Request
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param inheritedHierarchyTypeCode
 *          code of the {@link HierarchyType} being inherited.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "setInherited")
public ResponseIF setInheritedHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyTypeCode", required = true) String hierarchyTypeCode, @RequestParamter(name = "inheritedHierarchyTypeCode", required = true) String inheritedHierarchyTypeCode, @RequestParamter(name = "geoObjectTypeCode", required = true) String geoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().setInheritedHierarchy(request.getSessionId(), hierarchyTypeCode, inheritedHierarchyTypeCode, geoObjectTypeCode);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(ht.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 5 with HierarchyType

use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.

the class RegistryController method submitDataConflictResolution.

/**
 * Submit scheduled job conflict.
 *
 * @param sessionId
 * @param conflict
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = "registry/submit-conflict")
public ResponseIF submitDataConflictResolution(ClientRequestIF request, @RequestParamter(name = "conflict", required = true) String conflict) {
    // TODO: set this method up
    HierarchyType hierarchyType = ServiceFactory.getHierarchyService().createHierarchyType(request.getSessionId(), conflict);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(hierarchyType.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)40 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)21 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)12 Endpoint (com.runwaysdk.mvc.Endpoint)11 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)11 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)9 Test (org.junit.Test)9 JsonArray (com.google.gson.JsonArray)6 Request (com.runwaysdk.session.Request)6 JsonObject (com.google.gson.JsonObject)5 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)5 HierarchyNode (org.commongeoregistry.adapter.metadata.HierarchyNode)4 List (java.util.List)3 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)3 GeoObjectRelationshipPermissionServiceIF (net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF)3 TestUserInfo (net.geoprism.registry.test.TestUserInfo)3 SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)2 MdAttributeCharacterDAO (com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO)2 MdAttributeUUIDDAO (com.runwaysdk.dataaccess.metadata.MdAttributeUUIDDAO)2