Search in sources :

Example 51 with ServerGeoObjectIF

use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.

the class ValueOverTimeParentTest method testFullOverlapDifferentValue.

/**
 * Imported data is completely eclipsed by existing data, and the values are different.
 */
@Test
@Request
public void testFullOverlapDifferentValue() {
    ServerGeoObjectIF go = TEST_GO.getServerObject();
    go.addParent(BELIZE.getServerObject(), FastTestDataset.HIER_ADMIN.getServerObject(), addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, -5));
    go.apply(false);
    go = TEST_GO.getServerObject();
    ValueOverTimeCollection votc = go.getParentCollection(FastTestDataset.HIER_ADMIN.getServerObject());
    Assert.assertEquals(3, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
    Assert.assertEquals(TestDataSet.DEFAULT_OVER_TIME_DATE, vot.getStartDate());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 4), vot.getEndDate());
    ValueOverTime vot2 = votc.get(1);
    Assert.assertEquals(BELIZE.getCode(), ((ServerGeoObjectIF) vot2.getValue()).getCode());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5), vot2.getStartDate());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_END_TIME_DATE, -5), vot2.getEndDate());
    ValueOverTime vot3 = votc.get(2);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot3.getValue()).getCode());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_END_TIME_DATE, -4), vot3.getStartDate());
    Assert.assertEquals(TestDataSet.DEFAULT_END_TIME_DATE, vot3.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 52 with ServerGeoObjectIF

use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.

the class ValueOverTimeParentTest method testNoOverlap.

/**
 * Imported data has no conflict with any existing data in the system.
 */
@Test
@Request
public void testNoOverlap() {
    Calendar cStart = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
    cStart.clear();
    cStart.set(2005, Calendar.JANUARY, 1);
    Date start = cStart.getTime();
    Calendar cEnd = Calendar.getInstance(GeoRegistryUtil.SYSTEM_TIMEZONE);
    cEnd.clear();
    cEnd.set(2006, Calendar.JANUARY, 1);
    Date end = cEnd.getTime();
    ServerGeoObjectIF go = TEST_GO.getServerObject();
    go.addParent(FastTestDataset.CAMBODIA.getServerObject(), FastTestDataset.HIER_ADMIN.getServerObject(), start, end);
    go.apply(false);
    go = TEST_GO.getServerObject();
    ValueOverTimeCollection parents = go.getParentCollection(FastTestDataset.HIER_ADMIN.getServerObject());
    Assert.assertEquals(2, parents.size());
    ValueOverTime vot = parents.get(0);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
    Assert.assertEquals(start, vot.getStartDate());
    Assert.assertEquals(end, vot.getEndDate());
    ValueOverTime vot2 = parents.get(1);
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), ((ServerGeoObjectIF) vot2.getValue()).getCode());
    Assert.assertEquals(TestDataSet.DEFAULT_OVER_TIME_DATE, vot2.getStartDate());
    Assert.assertEquals(TestDataSet.DEFAULT_END_TIME_DATE, vot2.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Calendar(java.util.Calendar) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Date(java.util.Date) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 53 with ServerGeoObjectIF

use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.

the class ValueOverTimeTest method testFullConsumeDifferentValue.

/**
 * Imported data completely consumes existing data, and the values are different.
 */
@Test
@Request
public void testFullConsumeDifferentValue() {
    ServerGeoObjectIF go = TEST_GO.getServerObject();
    go.setValue(DefaultAttribute.EXISTS.getName(), false, addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5));
    go.apply(false);
    go = TEST_GO.getServerObject();
    ValueOverTimeCollection votc = go.getValuesOverTime(DefaultAttribute.EXISTS.getName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(false, vot.getValue());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, -5), vot.getStartDate());
    Assert.assertEquals(addDay(TestDataSet.DEFAULT_END_TIME_DATE, 5), vot.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 54 with ServerGeoObjectIF

use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.

the class ValueOverTimeTest method testStoreSameLocalizedValue.

@Test
@Request
public void testStoreSameLocalizedValue() {
    final String defaultValue = "default store";
    LocalizedValue original = new LocalizedValue(defaultValue);
    original.setValue(LocalizedValue.DEFAULT_LOCALE, defaultValue);
    ServerGeoObjectIF go = TEST_GO.getServerObject();
    go.setDisplayLabel(original, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
    go.apply(false);
    final String newValue = defaultValue;
    LocalizedValue lvNew = new LocalizedValue(newValue);
    lvNew.setValue(LocalizedValue.DEFAULT_LOCALE, newValue);
    ServerGeoObjectIF go2 = TEST_GO.getServerObject();
    go2.setDisplayLabel(lvNew, addDay(TestDataSet.DEFAULT_OVER_TIME_DATE, 5), addDay(TestDataSet.DEFAULT_END_TIME_DATE, -5));
    go2.apply(false);
    ServerGeoObjectIF go3 = TEST_GO.getServerObject();
    ValueOverTimeCollection votc = go3.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(defaultValue, ((VertexObjectDAO) vot.getValue()).getObjectValue(com.runwaysdk.constants.MdAttributeLocalInfo.DEFAULT_LOCALE));
    Assert.assertEquals(TestDataSet.DEFAULT_OVER_TIME_DATE, vot.getStartDate());
    Assert.assertEquals(TestDataSet.DEFAULT_END_TIME_DATE, vot.getEndDate());
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 55 with ServerGeoObjectIF

use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.

the class ListTypeVersion method publishNoAuth.

@Transaction
public String publishNoAuth() {
    this.lock();
    try {
        ListType masterlist = this.getListType();
        if (!masterlist.isValid()) {
            throw new InvalidMasterListException();
        }
        // Delete tile cache
        ListTileCache.deleteTiles(this);
        ListCurationHistory.deleteAll(this);
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        mdBusiness.deleteAllRecords();
        MdAttributeConcreteDAO status = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("status");
        if (status != null) {
            ListTypeAttributeGroup.remove(status);
            status.delete();
        }
        MdAttributeConcreteDAO statusDefaultLocale = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("statusDefaultLocale");
        if (statusDefaultLocale != null) {
            ListTypeAttributeGroup.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());
        Date forDate = this.getForDate();
        BasicVertexRestriction restriction = masterlist.getRestriction(type, forDate);
        BasicVertexQuery query = new BasicVertexQuery(type, forDate);
        query.setRestriction(restriction);
        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 BasicVertexQuery(type, forDate);
                query.setRestriction(restriction);
                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(masterlist, type, 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) Date(java.util.Date) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point) BasicVertexRestriction(net.geoprism.registry.query.graph.BasicVertexRestriction) BasicVertexQuery(net.geoprism.registry.query.graph.BasicVertexQuery) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) 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)106 Request (com.runwaysdk.session.Request)68 Test (org.junit.Test)43 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)28 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)23 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)18 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)18 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)16 Date (java.util.Date)15 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)15 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)13 LinkedList (java.util.LinkedList)11 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)10 JsonObject (com.google.gson.JsonObject)9 VertexObject (com.runwaysdk.business.graph.VertexObject)9 ChangeRequest (net.geoprism.registry.action.ChangeRequest)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)9