Search in sources :

Example 11 with Business

use of com.runwaysdk.business.Business in project geoprism-registry by terraframe.

the class MasterListVersion method publishNoAuth.

@Transaction
public String publishNoAuth() {
    this.lock();
    try {
        MasterList masterlist = this.getMasterlist();
        if (!masterlist.isValid()) {
            throw new InvalidMasterListException();
        }
        // Delete tile cache
        TileCache.deleteTiles(this);
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        mdBusiness.deleteAllRecords();
        MdAttributeConcreteDAO status = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("status");
        if (status != null) {
            MasterListAttributeGroup.remove(status);
            status.delete();
        }
        MdAttributeConcreteDAO statusDefaultLocale = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("statusDefaultLocale");
        if (statusDefaultLocale != null) {
            MasterListAttributeGroup.remove(statusDefaultLocale);
            statusDefaultLocale.delete();
        }
        ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
        Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
        // Add the type ancestor fields
        Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
        Collection<AttributeType> attributes = type.getAttributeMap().values();
        Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
        // ServerGeoObjectService service = new ServerGeoObjectService();
        // ServerGeoObjectQuery query = service.createQuery(type,
        // this.getPeriod());
        VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, this.getForDate());
        Long count = query.getCount();
        if (count == null) {
            count = 0L;
        }
        long current = 0;
        try {
            ProgressService.put(this.getOid(), new Progress(0L, count, ""));
            int pageSize = 1000;
            long skip = 0;
            while (skip < count) {
                query = new VertexGeoObjectQuery(type, this.getForDate());
                query.setLimit(pageSize);
                query.setSkip(skip);
                // List<GeoObjectStatus> validStats = new
                // ArrayList<GeoObjectStatus>();
                // validStats.add(GeoObjectStatus.ACTIVE);
                // validStats.add(GeoObjectStatus.INACTIVE);
                // validStats.add(GeoObjectStatus.PENDING);
                // validStats.add(GeoObjectStatus.NEW);
                // query.setRestriction(new ServerStatusRestriction(validStats,
                // this.getForDate(), JoinOp.OR));
                List<ServerGeoObjectIF> results = query.getResults();
                for (ServerGeoObjectIF result : results) {
                    Business business = new Business(mdBusiness.definesType());
                    publish(result, business, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
                    Thread.yield();
                    ProgressService.put(this.getOid(), new Progress(current++, count, ""));
                }
                skip += pageSize;
            }
            this.setPublishDate(new Date());
            this.apply();
            return this.toJSON(true).toString();
        } finally {
            ProgressService.remove(this.getOid());
        }
    } finally {
        this.unlock();
    }
}
Also used : Locale(java.util.Locale) MdAttributeConcreteDAO(com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Progress(net.geoprism.registry.progress.Progress) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Date(java.util.Date) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) MdAttributeLong(com.runwaysdk.system.metadata.MdAttributeLong) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 12 with Business

use of com.runwaysdk.business.Business in project geoprism-registry by terraframe.

the class MasterListVersion method updateRecord.

@Transaction
public void updateRecord(ServerGeoObjectIF object) {
    object.setDate(this.getForDate());
    // Delete tile cache
    TileCache.deleteTiles(this);
    MasterList masterlist = this.getMasterlist();
    MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
    Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
    // Add the type ancestor fields
    ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
    Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
    Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
    Collection<AttributeType> attributes = type.getAttributeMap().values();
    BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
    query.WHERE(query.aCharacter(DefaultAttribute.CODE.getName()).EQ(object.getCode()));
    List<Business> records = query.getIterator().getAll();
    for (Business record : records) {
        try {
            record.appLock();
            this.publish(object, record, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
        } finally {
            record.unlock();
        }
    }
}
Also used : Locale(java.util.Locale) BusinessQuery(com.runwaysdk.business.BusinessQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 13 with Business

use of com.runwaysdk.business.Business in project geoprism-registry by terraframe.

the class ListCurator method run.

public void run() {
    final ListType masterlist = version.getListType();
    final ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
    // final MdBusinessDAO mdBusiness =
    // MdBusinessDAO.get(version.getMdBusinessOid()).getBusinessDAO();
    BusinessQuery query = this.version.buildQuery(new JsonObject());
    query.ORDER_BY_DESC(query.aCharacter(DefaultAttribute.CODE.getName()));
    history.appLock();
    history.setWorkTotal(query.getCount());
    history.setWorkProgress(0L);
    history.apply();
    OIterator<Business> objects = query.getIterator();
    try {
        while (objects.hasNext()) {
            Business row = objects.next();
            final Geometry geom = row.getObjectValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
            final String code = row.getValue(DefaultAttribute.CODE.getName());
            if (geom == null) {
                GeoObjectProblem problem = new GeoObjectProblem();
                problem.setHistory(history);
                problem.setResolution(CurationResolution.UNRESOLVED.name());
                problem.setProblemType(GeoObjectProblemType.NO_GEOMETRY.name());
                problem.setTypeCode(type.getCode());
                problem.setGoCode(code);
                problem.setUid(row.getValue(DefaultAttribute.UID.getName()));
                problem.apply();
            }
            history.appLock();
            history.setWorkProgress(history.getWorkProgress() + 1);
            history.apply();
            if (history.getWorkProgress() % 100 == 0) {
                NotificationFacade.queue(new GlobalNotificationMessage(MessageType.CURATION_JOB_CHANGE, null));
            }
        }
    } finally {
        objects.close();
    }
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) Geometry(com.vividsolutions.jts.geom.Geometry) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Business(com.runwaysdk.business.Business)

Example 14 with Business

use of com.runwaysdk.business.Business in project geoprism-registry by terraframe.

the class ListTypeFhirExporter method populateBundle.

public void populateBundle(Bundle bundle) {
    BusinessQuery query = this.version.buildQuery(new JsonObject());
    query.ORDER_BY_DESC(query.aCharacter(DefaultAttribute.CODE.getName()));
    OIterator<Business> objects = query.getIterator();
    try {
        while (objects.hasNext()) {
            Business row = objects.next();
            String code = row.getValue(DefaultAttribute.CODE.getName());
            Identifier identifier = new Identifier();
            identifier.setValue(code);
            identifier.setUse(IdentifierUse.USUAL);
            identifier.setType(new CodeableConcept().addCoding(new Coding("http://terminology.hl7.org/CodeSystem/v2-0203", "RI", "Resource identifier")));
            String system = this.connection.getSystem();
            if (system != null) {
                identifier.setSystem(system);
            }
            Facility facility = createFacility(row, identifier);
            this.populator.populate(row, facility);
            // Add the organization and its corresponding location to the bundle
            createEntries(bundle, facility, identifier);
            this.populator.createExtraResources(row, bundle, facility);
        }
    } finally {
        objects.close();
    }
    this.populator.finish(bundle);
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) JsonObject(com.google.gson.JsonObject) Business(com.runwaysdk.business.Business) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 15 with Business

use of com.runwaysdk.business.Business in project geoprism-registry by terraframe.

the class ListTypeExcelExporter method createDataSheet.

private void createDataSheet(Workbook workbook) {
    Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(this.getList().getDisplayLabel().getValue()));
    Row header = sheet.createRow(0);
    // MdAttributeGeometryDAOIF geometryAttribute = (MdAttributeGeometryDAOIF)
    // this.mdBusiness.definesAttribute(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
    // 
    // boolean includeCoordinates = ( geometryAttribute instanceof
    // MdAttributePointDAOIF );
    this.writeHeader(this.boldStyle, header);
    int rownum = 1;
    BusinessQuery query = this.version.buildQuery(this.criteria);
    query.ORDER_BY_DESC(query.aCharacter(DefaultAttribute.CODE.getName()));
    OIterator<Business> objects = query.getIterator();
    try {
        while (objects.hasNext()) {
            Business object = objects.next();
            Row row = sheet.createRow(rownum++);
            this.writeRow(row, object, this.dateStyle);
        }
    } finally {
        objects.close();
    }
}
Also used : BusinessQuery(com.runwaysdk.business.BusinessQuery) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet) Point(com.vividsolutions.jts.geom.Point) Business(com.runwaysdk.business.Business)

Aggregations

Business (com.runwaysdk.business.Business)17 BusinessQuery (com.runwaysdk.business.BusinessQuery)12 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)8 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)7 LinkedList (java.util.LinkedList)7 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)6 List (java.util.List)6 Locale (java.util.Locale)6 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)6 JsonObject (com.google.gson.JsonObject)5 QueryFactory (com.runwaysdk.query.QueryFactory)5 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)4 Date (java.util.Date)4 Point (com.vividsolutions.jts.geom.Point)3 ArrayList (java.util.ArrayList)3 JsonArray (com.google.gson.JsonArray)2 VertexObject (com.runwaysdk.business.graph.VertexObject)2 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)2