Search in sources :

Example 1 with MdGeoVertexDAO

use of com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO in project geoprism-registry by terraframe.

the class GeoVertexType method remove.

public static void remove(String code) {
    MdGeoVertexDAO mdGeoVertex = getMdGeoVertex(code);
    mdGeoVertex.delete();
}
Also used : MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)

Example 2 with MdGeoVertexDAO

use of com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO 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 3 with MdGeoVertexDAO

use of com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO in project geoprism-registry by terraframe.

the class GeoVertexType method create.

/**
 * @param code
 * @param ownerActorId
 *          = the ID of the {@link ActorDAOIF} that is the owner of the
 *          {@link MdGeoVertexDAOIF}.
 * @param isAbstract
 *          TODO
 * @param parentType
 *          TODO
 * @return
 */
public static MdGeoVertexDAO create(String code, String ownerActorId, Boolean isAbstract, ServerGeoObjectType parentType) {
    MdVertexDAOIF parentVertexDAO = null;
    if (parentType == null) {
        parentVertexDAO = MdGeoVertexDAO.getMdGeoVertexDAO(GeoVertex.CLASS);
    } else {
        parentVertexDAO = parentType.getMdVertex();
    }
    MdGeoVertexDAO child = MdGeoVertexDAO.newInstance();
    child.setValue(MdGeoVertexInfo.PACKAGE, RegistryConstants.UNIVERSAL_GRAPH_PACKAGE);
    child.setValue(MdGeoVertexInfo.NAME, code);
    child.setValue(MdGeoVertexInfo.SUPER_MD_VERTEX, parentVertexDAO.getOid());
    child.setValue(MdGeoVertexInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.TRUE);
    child.setValue(MdGeoVertexInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
    child.setValue(MdGeoVertexInfo.OWNER, ownerActorId);
    child.setValue(MdGeoVertexInfo.ABSTRACT, isAbstract.toString());
    child.apply();
    return child;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)

Example 4 with MdGeoVertexDAO

use of com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO in project geoprism-registry by terraframe.

the class CRAttributePatch method patchAllGos.

private void patchAllGos() {
    for (Universal uni : getUniversals()) {
        MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
        List<? extends MdAttributeDAOIF> attributes = mdVertex.getAllDefinedMdAttributes();
        String[] skipAttrs = new String[] { DefaultAttribute.UID.getName(), "uuid", DefaultAttribute.CODE.getName(), DefaultAttribute.CREATE_DATE.getName(), DefaultAttribute.LAST_UPDATE_DATE.getName(), DefaultAttribute.SEQUENCE.getName(), DefaultAttribute.TYPE.getName(), MdAttributeConcreteInfo.OID, MdAttributeConcreteInfo.SEQUENCE };
        StringBuilder statement = new StringBuilder();
        statement.append("SELECT FROM " + mdVertex.getDBClassName());
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
        List<VertexObject> results = query.getResults();
        logger.info("Updating [" + results.size() + "] objects on table [" + mdVertex.getDBClassName() + "].");
        for (VertexObject vo : query.getResults()) {
            for (MdAttributeDAOIF attr : attributes) {
                if (!ArrayUtils.contains(skipAttrs, attr.definesAttribute())) {
                    ValueOverTimeCollection col = vo.getValuesOverTime(attr.definesAttribute());
                    for (ValueOverTime vot : col) {
                        vot.setOid(UUID.randomUUID().toString());
                    }
                }
            }
            vo.apply();
        }
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) VertexObject(com.runwaysdk.business.graph.VertexObject) ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 5 with MdGeoVertexDAO

use of com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method build.

public ServerGeoObjectType build(Universal universal) {
    MdBusiness mdBusiness = universal.getMdBusiness();
    MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(universal.getUniversalId());
    com.runwaysdk.system.gis.geo.GeometryType geoPrismgeometryType = universal.getGeometryType().get(0);
    org.commongeoregistry.adapter.constants.GeometryType cgrGeometryType = GeometryTypeFactory.get(geoPrismgeometryType);
    LocalizedValue label = convert(universal.getDisplayLabel());
    LocalizedValue description = convert(universal.getDescription());
    String ownerActerOid = universal.getOwnerOid();
    String organizationCode = Organization.getRootOrganizationCode(ownerActerOid);
    MdGeoVertexDAOIF superType = mdVertex.getSuperClass();
    GeoObjectType geoObjType = new GeoObjectType(universal.getUniversalId(), cgrGeometryType, label, description, universal.getIsGeometryEditable(), organizationCode, ServiceFactory.getAdapter());
    geoObjType.setIsAbstract(mdBusiness.getIsAbstract());
    try {
        GeoObjectTypeMetadata metadata = GeoObjectTypeMetadata.getByKey(universal.getKey());
        geoObjType.setIsPrivate(metadata.getIsPrivate());
    } catch (DataNotFoundException | AttributeDoesNotExistException e) {
        geoObjType.setIsPrivate(false);
    }
    if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
        String parentCode = superType.getTypeName();
        geoObjType.setSuperTypeCode(parentCode);
    }
    geoObjType = this.convertAttributeTypes(universal, geoObjType, mdBusiness);
    return new ServerGeoObjectType(geoObjType, universal, mdBusiness, mdVertex);
}
Also used : GeoObjectTypeMetadata(net.geoprism.registry.model.GeoObjectTypeMetadata) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdGeoVertexDAOIF(com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeDoesNotExistException(com.runwaysdk.dataaccess.AttributeDoesNotExistException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)

Aggregations

MdGeoVertexDAO (com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)6 Universal (com.runwaysdk.system.gis.geo.Universal)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)2 GeoObjectTypeMetadata (net.geoprism.registry.model.GeoObjectTypeMetadata)2 GraphQuery (com.runwaysdk.business.graph.GraphQuery)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 AttributeDoesNotExistException (com.runwaysdk.dataaccess.AttributeDoesNotExistException)1 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)1 MdGraphClassDAOIF (com.runwaysdk.dataaccess.MdGraphClassDAOIF)1 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)1 DataNotFoundException (com.runwaysdk.dataaccess.cache.DataNotFoundException)1 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)1 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)1 MdAttributeBooleanDAO (com.runwaysdk.dataaccess.metadata.MdAttributeBooleanDAO)1 MdAttributeCharacterDAO (com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO)1 MdAttributeConcreteDAO (com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO)1 MdAttributeEnumerationDAO (com.runwaysdk.dataaccess.metadata.MdAttributeEnumerationDAO)1