Search in sources :

Example 26 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class HierarchyExporter method exportUniversalInstances.

/**
 * Export all instances of the given {@link Universal} type.
 *
 * @param universal
 */
private static void exportUniversalInstances(ExportMetadata exportMetadata, Universal universal) {
    boolean isLeafType = universal.getIsLeafType();
    MdBusiness mdBusiness = universal.getMdBusiness();
    QueryFactory qf = new QueryFactory();
    BusinessDAOQuery q = qf.businessDAOQuery(mdBusiness.definesType());
    System.out.println("\nExporting Universal [" + universal.getUniversalId() + "] instances:");
    System.out.println("-----------------------------------------------------------------------");
    int counter = 0;
    OIterator<BusinessDAOIF> i = q.getIterator();
    try {
        for (BusinessDAOIF businessDAOIF : i) {
            if (!isLeafType) {
                BusinessDAOIF geoEntity = ((AttributeReferenceIF) businessDAOIF.getAttributeIF(RegistryConstants.GEO_ENTITY_ATTRIBUTE_NAME)).dereference();
                exportMetadata.addCreate(geoEntity);
            }
            exportMetadata.addCreate(businessDAOIF);
            System.out.print(".");
            if (counter % 100 == 0) {
                System.out.println();
            }
            counter++;
        }
    } finally {
        i.close();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) AttributeReferenceIF(com.runwaysdk.dataaccess.AttributeReferenceIF)

Example 27 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class HierarchyExporter method getUniversalRelationships.

/**
 * Returns a list of {@link MdTermRelationshipDAOIF} that defines relationships between universals.
 *
 * @return list of {@link MdTermRelationshipDAOIF} that defines relationships between universals.
 */
private static List<MdTermRelationshipDAOIF> getUniversalRelationships() {
    List<MdTermRelationshipDAOIF> list = new LinkedList<MdTermRelationshipDAOIF>();
    QueryFactory qf = new QueryFactory();
    // Export the MdTermRelationships that involve universals
    MdBusiness univMdBusiness = MdBusiness.getMdBusiness(Universal.CLASS);
    BusinessDAOQuery trQ = qf.businessDAOQuery(MdTermRelationship.CLASS);
    trQ.WHERE(trQ.get(MdTermRelationship.PARENTMDBUSINESS).EQ(univMdBusiness.getOid()).AND(trQ.get(MdTermRelationship.CHILDMDBUSINESS).EQ(univMdBusiness.getOid())));
    OIterator<? extends BusinessDAOIF> mdtrI = trQ.getIterator();
    try {
        while (mdtrI.hasNext()) {
            MdTermRelationshipDAOIF businessDAOIF = (MdTermRelationshipDAOIF) mdtrI.next();
            list.add(businessDAOIF);
        }
    } finally {
        mdtrI.close();
    }
    return list;
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) LinkedList(java.util.LinkedList)

Example 28 with MdBusiness

use of com.runwaysdk.system.metadata.MdBusiness in project geoprism-registry by terraframe.

the class ServerGeoObjectType method updateGeoObjectType.

@Transaction
private Universal updateGeoObjectType(GeoObjectType geoObjectType) {
    this.universal.lock();
    this.universal.setIsGeometryEditable(geoObjectType.isGeometryEditable());
    LocalizedValueConverter.populate(universal.getDisplayLabel(), geoObjectType.getLabel());
    LocalizedValueConverter.populate(universal.getDescription(), geoObjectType.getDescription());
    this.universal.apply();
    MdBusiness mdBusiness = universal.getMdBusiness();
    mdBusiness.lock();
    mdBusiness.getDisplayLabel().setValue(universal.getDisplayLabel().getValue());
    mdBusiness.getDescription().setValue(universal.getDescription().getValue());
    mdBusiness.apply();
    GeoObjectTypeMetadata metadata = this.getMetadata();
    if (!metadata.getIsPrivate().equals(geoObjectType.getIsPrivate())) {
        metadata.appLock();
        metadata.setIsPrivate(geoObjectType.getIsPrivate());
        metadata.apply();
    }
    mdBusiness.unlock();
    universal.unlock();
    return universal;
}
Also used : MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

MdBusiness (com.runwaysdk.system.metadata.MdBusiness)28 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)13 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)13 Locale (java.util.Locale)12 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)12 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)11 Business (com.runwaysdk.business.Business)10 LinkedList (java.util.LinkedList)10 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)10 QueryFactory (com.runwaysdk.query.QueryFactory)9 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)8 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)8 MdAttributeMultiPoint (com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint)8 MdAttributePoint (com.runwaysdk.system.gis.metadata.MdAttributePoint)8 MdAttributeCharacter (com.runwaysdk.system.metadata.MdAttributeCharacter)8 List (java.util.List)8 MdAttributeBoolean (com.runwaysdk.system.metadata.MdAttributeBoolean)7 MdAttributeDouble (com.runwaysdk.system.metadata.MdAttributeDouble)7 MdAttributeLong (com.runwaysdk.system.metadata.MdAttributeLong)7 JsonArray (com.google.gson.JsonArray)6