Search in sources :

Example 91 with ServerGeoObjectIF

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

the class ChangeRequestServiceTest method setUpTestInstanceData.

@Request
private void setUpTestInstanceData() {
    ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
    String votOid = cambodia.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName()).getValueOverTime(FastTestDataset.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE).getOid();
    UPDATE_ATTR_JSON = "{" + "\"valuesOverTime\" : [" + "{" + "\"oid\" : \"" + votOid + "\"," + "\"action\" : \"UPDATE\"," + "\"oldValue\" : \"" + FastTestDataset.CAMBODIA.getDefaultValue(FastTestDataset.AT_National_Anthem.getAttributeName()) + "\"," + "\"newValue\" : \"" + NEW_ANTHEM + "\"," + "\"newStartDate\" : \"" + NEW_START_DATE + "\"," + "\"newEndDate\" : \"" + NEW_END_DATE + "\"," + "\"oldStartDate\" : \"" + OLD_START_DATE + "\"," + "\"oldEndDate\" : \"" + OLD_END_DATE + "\"" + "}" + "]" + "}";
    ServerGeoObjectIF central_prov = FastTestDataset.PROV_CENTRAL.getServerObject();
    ServerParentTreeNode ptn = central_prov.getParentGeoObjects(new String[] { FastTestDataset.COUNTRY.getCode() }, false, TestDataSet.DEFAULT_OVER_TIME_DATE).getParents().get(0);
    UPDATE_PARENT_ATTR_JSON = "{" + "\"hierarchyCode\" : \"" + FastTestDataset.HIER_ADMIN.getCode() + "\"," + "\"valuesOverTime\" : [" + "{" + "\"oid\" : \"" + ptn.getOid() + "\"," + "\"action\" : \"UPDATE\"," + "\"oldValue\" : \"" + FastTestDataset.COUNTRY.getCode() + UpdateParentValueOverTimeView.VALUE_SPLIT_TOKEN + FastTestDataset.CAMBODIA.getCode() + "\"," + "\"newValue\" : \"" + FastTestDataset.COUNTRY.getCode() + UpdateParentValueOverTimeView.VALUE_SPLIT_TOKEN + BELIZE.getCode() + "\"," + "\"newStartDate\" : \"" + NEW_START_DATE + "\"," + "\"newEndDate\" : \"" + NEW_END_DATE + "\"," + "\"oldStartDate\" : \"" + OLD_START_DATE + "\"," + "\"oldEndDate\" : \"" + OLD_END_DATE + "\"" + "}" + "]" + "}";
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 92 with ServerGeoObjectIF

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

the class ChangeRequestServiceTest method testImplementDecisionsVerify.

@Request
private void testImplementDecisionsVerify(String crOid) throws Exception {
    ChangeRequest cr = ChangeRequest.get(crOid);
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getApprovalStatus().get(0).name());
    AbstractAction action = cr.getAllAction().next();
    Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), action.getApprovalStatus().get(0).name());
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    Date newStartDate = sdf.parse(NEW_START_DATE);
    Date newEndDate = sdf.parse(NEW_END_DATE);
    ServerGeoObjectIF serverGo = FastTestDataset.CAMBODIA.getServerObject();
    ValueOverTimeCollection votc = serverGo.getValuesOverTime(FastTestDataset.AT_National_Anthem.getAttributeName());
    Assert.assertEquals(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(newStartDate, vot.getStartDate());
    Assert.assertEquals(newEndDate, vot.getEndDate());
    Assert.assertEquals(NEW_ANTHEM, vot.getValue());
    Assert.assertEquals(NEW_ANTHEM, serverGo.getValue(FastTestDataset.AT_National_Anthem.getAttributeName(), newStartDate));
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 93 with ServerGeoObjectIF

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

the class RegistryVersionTest method addVersionData.

// @Test
// public void testSetAttributeVersions()
// {
// String attributeName = "status";
// AttributeType type = getAttributeType(attributeName);
// 
// ServerGeoObjectIF serverObj = testData.PROV_CENTRAL.getServerObject();
// 
// Assert.assertEquals(0, serverObj.getValuesOverTime(attributeName).size());
// 
// ValueOverTimeCollectionDTO dto = buildVersionDTO(type);
// 
// testData.adapter.setAttributeVersions(testData.PROV_CENTRAL.getCode(), testData.PROV_CENTRAL.getGeoObjectType().getCode(), "status", dto);
// 
// assertVersionData(ValueOverTimeConverter.colToDTO(serverObj.getValuesOverTime(attributeName), type));
// }
// 
// private void assertVersionData(ValueOverTimeCollectionDTO dto)
// {
// SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
// dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
// 
// Assert.assertEquals(3, dto.size());
// 
// try
// {
// Assert.assertEquals(dto.get(0).getValue(), GeoObjectStatus.INACTIVE);
// Assert.assertEquals(dto.get(0).getStartDate(), dateFormat.parse("01-01-1990"));
// Assert.assertEquals(dto.get(0).getEndDate(), dateFormat.parse("01-31-1990"));
// 
// Assert.assertEquals(dto.get(1).getValue(), GeoObjectStatus.NEW);
// Assert.assertEquals(dto.get(1).getStartDate(), dateFormat.parse("02-01-1990"));
// Assert.assertEquals(dto.get(1).getEndDate(), dateFormat.parse("02-28-1990"));
// 
// Assert.assertEquals(dto.get(2).getValue(), GeoObjectStatus.PENDING);
// Assert.assertEquals(dto.get(2).getStartDate(), dateFormat.parse("03-01-1990"));
// Assert.assertEquals(dto.get(2).getEndDate(), ValueOverTime.INFINITY_END_DATE);
// }
// catch (ParseException e)
// {
// throw new RuntimeException(e);
// }
// }
// 
@Request
@SuppressWarnings("unchecked")
private void addVersionData(TestGeoObjectInfo geoObj) throws ParseException {
    SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy");
    dateFormat.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    ServerGeoObjectIF serverObj = geoObj.getServerObject();
    serverObj.getValuesOverTime(DefaultAttribute.EXISTS.getName()).clear();
    serverObj.setExists(Boolean.FALSE, dateFormat.parse("01-01-1990"), dateFormat.parse("01-31-1990"));
    Assert.assertEquals(Boolean.FALSE, serverObj.getExists(dateFormat.parse("01-01-1990")));
    serverObj.setExists(Boolean.TRUE, dateFormat.parse("02-01-1990"), dateFormat.parse("02-28-1990"));
    Assert.assertEquals(Boolean.TRUE, serverObj.getExists(dateFormat.parse("02-01-1990")));
    serverObj.setExists(Boolean.FALSE, dateFormat.parse("03-01-1990"), dateFormat.parse("03-31-1990"));
    Assert.assertEquals(Boolean.FALSE, serverObj.getExists(dateFormat.parse("03-01-1990")));
    serverObj.apply(false);
    Assert.assertEquals(Boolean.FALSE, serverObj.getExists(dateFormat.parse("01-01-1990")));
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) SimpleDateFormat(java.text.SimpleDateFormat) Request(com.runwaysdk.session.Request)

Example 94 with ServerGeoObjectIF

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

the class SearchServiceTest method testSearchTable.

@Test
@Request
public void testSearchTable() {
    SearchService service = new SearchService();
    service.clear();
    service.deleteSearchTable();
    service.createSearchTable();
    new SearchTablePatch().createRecords(service);
    Date date = USATestData.DEFAULT_OVER_TIME_DATE;
    List<ServerGeoObjectIF> results = service.search(USATestData.CO_D_ONE.getDisplayLabel(), date, 10L);
    Assert.assertEquals(1, results.size());
    ServerGeoObjectIF result = results.get(0);
    Assert.assertEquals(result.getCode(), USATestData.CO_D_ONE.getCode());
    Assert.assertEquals(3, service.search(USATestData.TEST_DATA_KEY + "ColoradoDistrict", date, 10L).size());
    Assert.assertEquals(1, service.search(USATestData.TEST_DATA_KEY, date, 1L).size());
}
Also used : SearchTablePatch(com.runwaysdk.build.domain.SearchTablePatch) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Date(java.util.Date) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 95 with ServerGeoObjectIF

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

the class ValueOverTimeParentTest method testFullConsumeDifferentValue.

/**
 * Imported data completely consumes existing data, and the values are different.
 */
@Test
@Request
public void testFullConsumeDifferentValue() {
    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(1, votc.size());
    ValueOverTime vot = votc.get(0);
    Assert.assertEquals(BELIZE.getCode(), ((ServerGeoObjectIF) vot.getValue()).getCode());
    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)

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