Search in sources :

Example 31 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class PatchExistsAndInvalid method addAttributes.

@Transaction
private void addAttributes() {
    List<Universal> unis = getUniversals();
    for (Universal uni : unis) {
        MdBusinessDAO bizDAO = (MdBusinessDAO) BusinessFacade.getEntityDAO(uni.getMdBusiness());
        MdAttributeConcreteDAO postgresStatusAttr = (MdAttributeConcreteDAO) bizDAO.definesAttribute(STATUS_ATTRIBUTE_NAME);
        if (postgresStatusAttr != null) {
            postgresStatusAttr.delete();
        }
        MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
        MdAttributeEnumerationDAO statusMdAttr = (MdAttributeEnumerationDAO) mdVertex.definesAttribute(STATUS_ATTRIBUTE_NAME);
        if (statusMdAttr != null) {
            statusMdAttr.delete();
        }
    }
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        MdAttributeDAOIF existing = mdClass.definesAttribute(DefaultAttribute.EXISTS.getName());
        if (existing == null) {
            logger.info("Adding new attributes to [" + mdClass.getKey() + "].");
            MdAttributeBooleanDAO existsMdAttr = MdAttributeBooleanDAO.newInstance();
            existsMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.EXISTS.getName());
            existsMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultLocalizedName());
            existsMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultDescription());
            existsMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
            existsMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
            existsMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
            existsMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
            existsMdAttr.apply();
            MdAttributeBooleanDAO invalidMdAttr = MdAttributeBooleanDAO.newInstance();
            invalidMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.INVALID.getName());
            invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultLocalizedName());
            invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultDescription());
            invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
            invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
            invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
            invalidMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
            invalidMdAttr.apply();
        }
    }
    patchMasterlistVersions();
// TODO : We can't actually set this field to required unfortunately because of many different graph bugs.
// If we set it to required immediately when it's created, orientdb throws an error saying that objects
// don't have a required field. If we try to update the field to set it as required after the instance
// data has been patched, Runway tries to create the attribute twice because the MdAttribute in the cache
// still has the 'isNew' flag set to true. We can't do this in a separate transaction because the patching
// transaction is controlled at a higher level than we have access to here.
// enforceInvalidRequired();
}
Also used : MdAttributeConcreteDAO(com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO) Universal(com.runwaysdk.system.gis.geo.Universal) MdAttributeEnumerationDAO(com.runwaysdk.dataaccess.metadata.MdAttributeEnumerationDAO) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeBooleanDAO(com.runwaysdk.dataaccess.metadata.MdAttributeBooleanDAO) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 32 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class PatchExistsAndInvalid method enforceInvalidRequired.

private void enforceInvalidRequired() {
    List<Universal> unis = PatchExistsAndInvalid.getUniversals();
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        logger.info("Setting invalid mdAttr to required for class [" + mdClass.getKey() + "].");
        MdAttributeDAO invalidMdAttr = (MdAttributeDAO) mdClass.definesAttribute(DefaultAttribute.INVALID.getName());
        invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
        invalidMdAttr.apply();
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) MdAttributeDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDAO)

Example 33 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class PatchExistsAndInvalidInstanceData method patchInstanceData.

private void patchInstanceData() {
    List<Universal> unis = PatchExistsAndInvalid.getUniversals();
    int applied = 0;
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        List<VertexServerGeoObject> data = getInstanceData(type, mdClass);
        int current = 0;
        final int size = data.size();
        logger.info("Starting to patch instance data for type [" + mdClass.getDBClassName() + "] with count [" + size + "] ");
        for (VertexServerGeoObject go : data) {
            ValueOverTime defaultExists = go.buildDefaultExists();
            if (defaultExists != null) {
                go.setValue(DefaultAttribute.EXISTS.getName(), Boolean.TRUE, defaultExists.getStartDate(), defaultExists.getEndDate());
                go.setValue(DefaultAttribute.INVALID.getName(), false);
                // This apply method is mega slow due to the SearchService so we're going to just bypass it
                // go.apply(false);
                go.getVertex().setValue(GeoVertex.LASTUPDATEDATE, new Date());
                go.getVertex().apply();
                applied++;
            }
            if (current % 100 == 0) {
                logger.info("Finished record " + current + " of " + size);
            }
            current++;
        }
    }
    logger.info("Applied " + applied + " records across " + unis.size() + " types.");
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Date(java.util.Date)

Example 34 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class PatchInheritedAnnotation method transaction.

@Transaction
private void transaction() {
    InheritedHierarchyAnnotationQuery query = new InheritedHierarchyAnnotationQuery(new QueryFactory());
    query.ORDER_BY(query.getForHierarchicalRelationshipType(), SortOrder.DESC);
    query.ORDER_BY(query.getCreateDate(), SortOrder.DESC);
    try (OIterator<? extends InheritedHierarchyAnnotation> iterator = query.getIterator()) {
        InheritedHierarchyAnnotation prev = null;
        while (iterator.hasNext()) {
            InheritedHierarchyAnnotation annotation = iterator.next();
            if (prev != null && prev.getForHierarchicalRelationshipTypeOid().equals(annotation.getForHierarchicalRelationshipTypeOid())) {
                annotation.delete();
            } else if (annotation.getForHierarchicalRelationshipTypeOid() == null || annotation.getForHierarchicalRelationshipTypeOid().length() == 0) {
                annotation.delete();
            } else {
                // Determine if the inherited hierarchy and for hierarchy have the
                // same root
                ServerGeoObjectType inheritedNode = ServerGeoObjectType.get(annotation.getUniversal());
                HierarchicalRelationshipType inheritedHierarchicalType = annotation.getInheritedHierarchicalRelationshipType();
                ServerHierarchyType inheritedHierarchy = new ServerHierarchyTypeBuilder().get(inheritedHierarchicalType);
                Set<String> rootCodes = inheritedHierarchy.getRootGeoObjectTypes().stream().map(type -> type.getGeoObjectType().getCode()).collect(Collectors.toSet());
                if (rootCodes.contains(inheritedNode.getCode())) {
                    annotation.delete();
                } else {
                    prev = annotation;
                }
            }
        }
    }
}
Also used : InheritedHierarchyAnnotationQuery(net.geoprism.registry.InheritedHierarchyAnnotationQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) Set(java.util.Set) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) HierarchicalRelationshipType(net.geoprism.registry.HierarchicalRelationshipType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 35 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class CurationService method curate.

@Request(RequestType.SESSION)
public JsonObject curate(String sessionId, String listTypeVersionId) {
    final ListTypeVersion version = ListTypeVersion.get(listTypeVersionId);
    final ListType listType = version.getListType();
    final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
    final String orgCode = listType.getOrganization().getCode();
    this.checkPermissions(orgCode, serverGOT);
    ListCurationJob job = new ListCurationJob();
    job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
    job.apply();
    ListCurationHistory history = job.start(version);
    return this.serializeHistory(history, GeoprismUser.get(job.getRunAsUser().getOid()), job);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Aggregations

ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)201 Request (com.runwaysdk.session.Request)69 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)57 JsonObject (com.google.gson.JsonObject)48 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)32 JsonArray (com.google.gson.JsonArray)30 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)30 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)27 LinkedList (java.util.LinkedList)27 Test (org.junit.Test)27 VertexObject (com.runwaysdk.business.graph.VertexObject)26 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)26 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)23 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)23 Date (java.util.Date)21 GraphQuery (com.runwaysdk.business.graph.GraphQuery)19 List (java.util.List)18 EdgeObject (com.runwaysdk.business.graph.EdgeObject)17 SimpleDateFormat (java.text.SimpleDateFormat)17 Locale (java.util.Locale)17