Search in sources :

Example 1 with VertexGeoObjectQuery

use of net.geoprism.registry.query.graph.VertexGeoObjectQuery in project geoprism-registry by terraframe.

the class GeoObjectQueryTest method testQueryTreeNodes.

@Test
@Request
public void testQueryTreeNodes() {
    ServerGeoObjectType type = USATestData.STATE.getServerObject();
    VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, null);
    List<ServerGeoObjectIF> results = query.getResults();
    Assert.assertEquals(2, results.size());
    ServerGeoObjectIF result = results.get(0);
    Assert.assertEquals(USATestData.COLORADO.getCode(), result.getCode());
    Assert.assertNotNull(result.getGeometry());
    Assert.assertEquals(USATestData.COLORADO.getDisplayLabel(), result.getDisplayLabel().getValue());
    Assert.assertEquals(true, result.getExists());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 2 with VertexGeoObjectQuery

use of net.geoprism.registry.query.graph.VertexGeoObjectQuery in project geoprism-registry by terraframe.

the class GeoObjectQueryTest method testLeafCodeRestriction.

@Test
@Request
public void testLeafCodeRestriction() {
    ServerGeoObjectType type = USATestData.DISTRICT.getServerObject();
    VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, null);
    query.setRestriction(new ServerCodeRestriction(USATestData.CO_D_ONE.getCode()));
    ServerGeoObjectIF result = query.getSingleResult();
    Assert.assertEquals(USATestData.CO_D_ONE.getCode(), result.getCode());
    Assert.assertNotNull(result.getGeometry());
    Assert.assertEquals(USATestData.CO_D_ONE.getDisplayLabel(), result.getDisplayLabel().getValue());
    Assert.assertEquals(true, result.getExists());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) ServerCodeRestriction(net.geoprism.registry.query.ServerCodeRestriction) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 3 with VertexGeoObjectQuery

use of net.geoprism.registry.query.graph.VertexGeoObjectQuery in project geoprism-registry by terraframe.

the class GeoObjectQueryTest method testTreeSynonymRestrictionByCode.

@Test
@Request
public void testTreeSynonymRestrictionByCode() {
    ServerGeoObjectType type = USATestData.STATE.getServerObject();
    VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, null);
    query.setRestriction(new ServerSynonymRestriction(USATestData.COLORADO.getCode(), USATestData.COLORADO.getDate()));
    ServerGeoObjectIF result = query.getSingleResult();
    Assert.assertEquals(USATestData.COLORADO.getCode(), result.getCode());
    Assert.assertNotNull(result.getGeometry());
    Assert.assertEquals(USATestData.COLORADO.getDisplayLabel(), result.getDisplayLabel().getValue());
    Assert.assertEquals(true, result.getExists());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) ServerSynonymRestriction(net.geoprism.registry.query.ServerSynonymRestriction) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 4 with VertexGeoObjectQuery

use of net.geoprism.registry.query.graph.VertexGeoObjectQuery in project geoprism-registry by terraframe.

the class GeoObjectQueryTest method testFailLookupRestriction.

@Test
@Request
public void testFailLookupRestriction() {
    ServerGeoObjectType type = USATestData.STATE.getServerObject();
    ServerLookupRestriction restriction = new ServerLookupRestriction(USATestData.CANADA.getCode(), USATestData.CANADA.getDate());
    VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, null);
    query.setRestriction(restriction);
    ServerGeoObjectIF result = query.getSingleResult();
    Assert.assertNull(result);
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerLookupRestriction(net.geoprism.registry.query.ServerLookupRestriction) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 5 with VertexGeoObjectQuery

use of net.geoprism.registry.query.graph.VertexGeoObjectQuery 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)

Aggregations

ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)7 VertexGeoObjectQuery (net.geoprism.registry.query.graph.VertexGeoObjectQuery)7 Request (com.runwaysdk.session.Request)6 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)6 Test (org.junit.Test)6 Date (java.util.Date)2 ServerSynonymRestriction (net.geoprism.registry.query.ServerSynonymRestriction)2 Business (com.runwaysdk.business.Business)1 MdAttributeConcreteDAO (com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 MdAttributeMultiPoint (com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint)1 MdAttributePoint (com.runwaysdk.system.gis.metadata.MdAttributePoint)1 MdAttributeLong (com.runwaysdk.system.metadata.MdAttributeLong)1 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Locale (java.util.Locale)1 RevealExternalSystem (net.geoprism.registry.graph.RevealExternalSystem)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1