Search in sources :

Example 46 with MdVertexDAOIF

use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.

the class SearchTablePatch method createRecords.

@Transaction
public void createRecords(SearchService service) {
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
    long pageSize = 1000;
    long skip = 0;
    int count = 0;
    do {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        builder.append(" ORDER BY oid");
        builder.append(" SKIP " + skip + " LIMIT " + pageSize);
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
        List<VertexObject> results = query.getResults();
        for (VertexObject result : results) {
            ServerGeoObjectType type = ServerGeoObjectType.get((MdVertexDAOIF) result.getMdClass());
            service.insert(new VertexServerGeoObject(type, result));
        }
        skip += pageSize;
        count = results.size();
    } while (count > 0);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 47 with MdVertexDAOIF

use of com.runwaysdk.dataaccess.MdVertexDAOIF 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)

Example 48 with MdVertexDAOIF

use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.

the class GeoObjectJsonExporter method count.

public Long count() {
    MdVertexDAOIF mdVertex = got.getMdVertex();
    MdAttributeDAOIF mdAttribute = MdAttributeDAO.getByKey(GeoVertex.CLASS + "." + GeoVertex.LASTUPDATEDATE);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
    if (this.since != null) {
        statement.append(" WHERE " + mdAttribute.getColumnName() + " >= :lastUpdateDate");
    }
    statement.append(" ORDER BY " + mdAttribute.getColumnName() + ", oid ASC");
    GraphQuery<Long> query = new GraphQuery<Long>(statement.toString());
    if (this.since != null) {
        query.setParameter("lastUpdateDate", this.since);
    }
    return query.getSingleResult();
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 49 with MdVertexDAOIF

use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.

the class BusinessObjectImporter method setClassificationValue.

protected void setClassificationValue(BusinessObject entity, AttributeType attributeType, String attributeName, Object value) {
    if (!this.configuration.isExclusion(attributeName, value.toString())) {
        try {
            BusinessType type = this.configuration.getType();
            MdVertexDAOIF mdBusiness = type.getMdVertexDAO();
            MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
            VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
            if (classifier == null) {
                throw new UnknownTermException(value.toString().trim(), attributeType);
            } else {
                entity.setValue(attributeName, classifier.getOid());
            }
        } catch (UnknownTermException e) {
            TermValueException ex = new TermValueException();
            ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
            ex.setCode(e.getCode());
            throw e;
        }
    }
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) VertexObject(com.runwaysdk.business.graph.VertexObject) BusinessType(net.geoprism.registry.BusinessType) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 50 with MdVertexDAOIF

use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.

the class BusinessObject method get.

public static BusinessObject get(BusinessType type, String attributeName, Object value) {
    MdVertexDAOIF mdVertex = type.getMdVertexDAO();
    MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(attributeName);
    StringBuilder statement = new StringBuilder();
    statement.append("SELECT FROM " + mdVertex.getDBClassName());
    statement.append(" WHERE " + mdAttribute.getColumnName() + " = :" + attributeName);
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    query.setParameter(attributeName, value);
    VertexObject result = query.getSingleResult();
    if (result != null) {
        return new BusinessObject(result, type);
    }
    return null;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Aggregations

MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)62 GraphQuery (com.runwaysdk.business.graph.GraphQuery)34 VertexObject (com.runwaysdk.business.graph.VertexObject)30 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)26 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)24 EdgeObject (com.runwaysdk.business.graph.EdgeObject)16 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)11 Date (java.util.Date)10 LinkedList (java.util.LinkedList)9 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)8 JsonObject (com.google.gson.JsonObject)7 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)7 HashedMap (org.apache.commons.collections4.map.HashedMap)7 HashMap (java.util.HashMap)5 TreeSet (java.util.TreeSet)5 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)5 GraphObject (com.runwaysdk.business.graph.GraphObject)4 MdVertexDAO (com.runwaysdk.dataaccess.metadata.graph.MdVertexDAO)4 LineString (com.vividsolutions.jts.geom.LineString)4