Search in sources :

Example 6 with MdBusinessDAOIF

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

the class ClearTileCache method doIt.

@Transaction
private void doIt() {
    MdBusinessDAOIF mdBusiness = MdBusinessDAO.getMdBusinessDAO(TileCache.CLASS);
    mdBusiness.getBusinessDAO().deleteAllRecords();
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with MdBusinessDAOIF

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

the class GeoObjectImporter method setTermValue.

protected void setTermValue(ServerGeoObjectIF entity, AttributeType attributeType, String attributeName, Object value, Date startDate, Date endDate) {
    if (!this.configuration.isExclusion(attributeName, value.toString())) {
        try {
            ServerGeoObjectType type = this.configuration.getType();
            MdBusinessDAOIF mdBusiness = type.getMdBusinessDAO();
            MdAttributeTermDAOIF mdAttribute = (MdAttributeTermDAOIF) mdBusiness.definesAttribute(attributeName);
            if (mdAttribute == null && type.getSuperType() != null) {
                mdAttribute = (MdAttributeTermDAOIF) type.getSuperType().getMdBusinessDAO().definesAttribute(attributeName);
            }
            Classifier classifier = Classifier.findMatchingTerm(value.toString().trim(), mdAttribute);
            if (classifier == null) {
                Term rootTerm = ((AttributeTermType) attributeType).getRootTerm();
                TermReferenceProblem trp = new TermReferenceProblem(value.toString(), rootTerm.getCode(), mdAttribute.getOid(), attributeName, attributeType.getLabel().getValue());
                trp.addAffectedRowNumber(this.progressListener.getWorkProgress() + 1);
                trp.setHistoryId(this.configuration.getHistoryId());
                this.progressListener.addReferenceProblem(trp);
            } else {
                entity.setValue(attributeName, classifier.getOid(), startDate, endDate);
            }
        } catch (UnknownTermException e) {
            TermValueException ex = new TermValueException();
            ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
            ex.setCode(e.getCode());
            throw e;
        }
    }
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeTermDAOIF(com.runwaysdk.dataaccess.MdAttributeTermDAOIF) Classifier(net.geoprism.ontology.Classifier) Term(org.commongeoregistry.adapter.Term) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) TermReferenceProblem(net.geoprism.registry.etl.TermReferenceProblem) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 8 with MdBusinessDAOIF

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

the class GeoObjectImporter method setClassificationValue.

protected void setClassificationValue(ServerGeoObjectIF entity, AttributeType attributeType, String attributeName, Object value, Date startDate, Date endDate) {
    if (!this.configuration.isExclusion(attributeName, value.toString())) {
        try {
            ServerGeoObjectType type = this.configuration.getType();
            MdBusinessDAOIF mdBusiness = type.getMdBusinessDAO();
            MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
            if (mdAttribute == null && type.getSuperType() != null) {
                mdAttribute = (MdAttributeClassificationDAOIF) type.getSuperType().getMdBusinessDAO().definesAttribute(attributeName);
            }
            VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
            if (classifier == null) {
                throw new UnknownTermException(value.toString().trim(), attributeType);
            // Term rootClassification = ( (AttributeClassificationType) attributeType ).getRootTerm();
            // 
            // TermReferenceProblem trp = new TermReferenceProblem(value.toString(), rootClassification.getCode(), mdAttribute.getOid(), attributeName, attributeType.getLabel().getValue());
            // trp.addAffectedRowNumber(this.progressListener.getWorkProgress() + 1);
            // trp.setHistoryId(this.configuration.getHistoryId());
            // 
            // this.progressListener.addReferenceProblem(trp);
            } else {
                entity.setValue(attributeName, classifier.getOid(), startDate, endDate);
            }
        } catch (UnknownTermException e) {
            TermValueException ex = new TermValueException();
            ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
            ex.setCode(e.getCode());
            throw e;
        }
    }
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 9 with MdBusinessDAOIF

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

the class ListTypeExcelExporter method createMetadataSheet.

private void createMetadataSheet(Workbook workbook) {
    Sheet sheet = workbook.createSheet(this.getSheetName(workbook, "masterlist.metadata"));
    Locale locale = Session.getCurrentLocale();
    MdBusinessDAOIF metadata = MdBusinessDAO.getMdBusinessDAO(ListType.CLASS);
    int rowNumber = 0;
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.DISPLAYLABEL, this.list.getDisplayLabel().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.CODE, this.list.getCode());
    this.createRow(sheet, rowNumber++, LocalizationFacade.getFromBundles("masterlist.publishDate"), stripTime(this.version.getPublishDate()));
    this.createRow(sheet, rowNumber++, LocalizationFacade.getFromBundles("masterlist.forDate"), stripTime(this.version.getForDate()));
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.DESCRIPTION, this.list.getDescription().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTORIGINATOR, this.list.getOrganization());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTLABEL, this.list.getListLabel().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTDESCRIPTION, this.list.getListDescription().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTPROCESS, this.list.getListProcess().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTPROGRESS, this.list.getListProgress());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTACCESSCONSTRAINTS, this.list.getListAccessConstraints().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTUSECONSTRAINTS, this.list.getListAcknowledgements().getValue());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTDISCLAIMER, this.list.getListDisclaimer().getValue());
    rowNumber++;
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTCONTACTNAME, this.list.getListContactName());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTORGANIZATION, this.list.getListOrganization());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTTELEPHONENUMBER, this.list.getListTelephoneNumber());
    this.createRow(sheet, locale, metadata, rowNumber++, ListType.LISTEMAIL, this.list.getListEmail());
}
Also used : Locale(java.util.Locale) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) Sheet(org.apache.poi.ss.usermodel.Sheet) Point(com.vividsolutions.jts.geom.Point)

Example 10 with MdBusinessDAOIF

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

the class HierarchyExporter method exportHierarchyDefinition.

/**
 * Exports the metadata for the hierarchies. If a
 * file of the specified filename already exists then the file is overwritten.
 *
 * @param fileName
 *            The name of the xml file to create.
 * @param schemaLocation
 *            The location of the schema
 * @param _exportOnlyModifiedAttributes
 *             True if only modified attributes should be exported, false otherwise.
 */
@Request
public static void exportHierarchyDefinition(String fileName, String schemaLocation, boolean _exportOnlyModifiedAttributes) {
    ExportMetadata exportMetadata = new ExportMetadata();
    QueryFactory qf = new QueryFactory();
    // Export the MdBusinesses that define the hierarchy attributes
    BusinessDAOQuery uQ = qf.businessDAOQuery(Universal.CLASS);
    BusinessDAOQuery mdbQ = qf.businessDAOQuery(MdBusiness.CLASS);
    mdbQ.WHERE(mdbQ.aUUID(MdBusiness.OID).EQ(uQ.aReference(Universal.MDBUSINESS).aUUID(Universal.OID)));
    OIterator<? extends BusinessDAOIF> mdbI = mdbQ.getIterator();
    try {
        while (mdbI.hasNext()) {
            MdBusinessDAOIF mdBusiness = (MdBusinessDAOIF) mdbI.next();
            System.out.println(mdBusiness.getType() + "  " + mdBusiness.getTypeName());
            exportMetadata.addCreateOrUpdate(mdBusiness);
        }
    } finally {
        mdbI.close();
    }
    // Export the Universals
    uQ = qf.businessDAOQuery(Universal.CLASS);
    OIterator<? extends BusinessDAOIF> uQI = uQ.getIterator();
    try {
        while (uQI.hasNext()) {
            BusinessDAOIF businessDAOIF = (BusinessDAOIF) uQI.next();
            System.out.println(businessDAOIF.getType() + "  " + businessDAOIF.getKey());
            exportMetadata.addCreateOrUpdate(businessDAOIF);
        }
    } finally {
        mdbI.close();
    }
    // Export the MdTermRelationships that involve universals
    List<MdTermRelationshipDAOIF> universalRelList = getUniversalRelationships();
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : universalRelList) {
        System.out.println(mdTermRelationshipDAOIF.getType() + "  " + mdTermRelationshipDAOIF.getKey());
        exportMetadata.addCreateOrUpdate(mdTermRelationshipDAOIF);
    }
    // Export the instances of the relationships between the universals.
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : universalRelList) {
        RelationshipDAOQuery relQ = qf.relationshipDAOQuery(mdTermRelationshipDAOIF.definesType());
        OIterator<RelationshipDAOIF> relI = relQ.getIterator();
        try {
            while (relI.hasNext()) {
                RelationshipDAOIF relationshipDAOIF = relI.next();
                exportMetadata.addCreateOrUpdate(relationshipDAOIF);
            }
        } finally {
            relI.close();
        }
    }
    List<MdTermRelationshipDAOIF> geoEntityRelList = getGeoEntityRelationships();
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : geoEntityRelList) {
        System.out.println(mdTermRelationshipDAOIF.getType() + "  " + mdTermRelationshipDAOIF.getKey());
        exportMetadata.addCreateOrUpdate(mdTermRelationshipDAOIF);
    }
    VersionExporter.export(fileName, schemaLocation, exportMetadata);
// FileInstanceExporter.export(fileName, schemaLocation, queries, _exportOnlyModifiedAttributes);
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) ExportMetadata(com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) RelationshipDAOIF(com.runwaysdk.dataaccess.RelationshipDAOIF) RelationshipDAOQuery(com.runwaysdk.query.RelationshipDAOQuery) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) Request(com.runwaysdk.session.Request)

Aggregations

MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)30 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)18 JsonObject (com.google.gson.JsonObject)15 Date (java.util.Date)11 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)10 BusinessQuery (com.runwaysdk.business.BusinessQuery)9 IOException (java.io.IOException)9 SimpleDateFormat (java.text.SimpleDateFormat)9 Locale (java.util.Locale)9 JsonArray (com.google.gson.JsonArray)8 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 QueryFactory (com.runwaysdk.query.QueryFactory)8 InputStream (java.io.InputStream)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)7 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)7 ParseException (java.text.ParseException)7 JsonParser (com.google.gson.JsonParser)6