Search in sources :

Example 96 with LocalizedValue

use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.

the class XMLImporter method createTermOptions.

private void createTermOptions(Element attributeNode, Term root) {
    NodeList attributeList = attributeNode.getElementsByTagName("option");
    for (int i = 0; i < attributeList.getLength(); i++) {
        Node nNode = attributeList.item(i);
        if (nNode.getNodeType() == Node.ELEMENT_NODE) {
            Element elem = (Element) nNode;
            String code = elem.getAttribute("code");
            LocalizedValue label = this.getLabel(elem);
            LocalizedValue description = this.getDescription(elem);
            Term term = new Term(code, label, description);
            Classifier classifier = TermConverter.createClassifierFromTerm(root.getCode(), term);
            TermConverter termBuilder = new TermConverter(classifier.getKeyName());
            termBuilder.build();
        }
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ServerElement(net.geoprism.registry.model.ServerElement) Element(org.w3c.dom.Element) Term(org.commongeoregistry.adapter.Term) Classifier(net.geoprism.ontology.Classifier) TermConverter(net.geoprism.registry.conversion.TermConverter)

Example 97 with LocalizedValue

use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.

the class TestHierarchyTypeInfo method toDTO.

public HierarchyType toDTO() {
    LocalizedValue displayLabel = new LocalizedValue(this.displayLabel);
    LocalizedValue description = new LocalizedValue(this.displayLabel);
    HierarchyType ht = new HierarchyType(this.code, displayLabel, description, this.getOrganization().getCode());
    return ht;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType)

Example 98 with LocalizedValue

use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.

the class ConversionTest method testAttributeTypeDateTree.

@Test
public void testAttributeTypeDateTree() {
    String sessionId = testData.clientRequest.getSessionId();
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2019, Calendar.JANUARY, 12, 20, 21, 32);
    // Add a new custom attribute
    AttributeType testDate = AttributeType.factory("testDate", new LocalizedValue("testDateLocalName"), new LocalizedValue("testDateLocalDescrip"), AttributeDateType.TYPE, false, false, false);
    testDate = ServiceFactory.getRegistryService().createAttributeType(sessionId, USATestData.STATE.getCode(), testDate.toJSON().toString());
    // Create a new GeoObject with the custom attribute
    GeoObject geoObj = ServiceFactory.getRegistryService().newGeoObjectInstance(sessionId, USATestData.STATE.getCode());
    geoObj.setCode(testGo.getCode());
    geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, "Test Label");
    geoObj.setUid(ServiceFactory.getRegistryService().getUIDS(sessionId, 1)[0]);
    geoObj.setValue(testDate.getName(), calendar.getTime());
    ServiceFactory.getRegistryService().createGeoObject(sessionId, geoObj.toJSON().toString(), TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE);
    // Get the object with the custom attribute
    GeoObject result = ServiceFactory.getRegistryService().getGeoObjectByCode(sessionId, testGo.getCode(), USATestData.STATE.getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
    Assert.assertNotNull(result);
    Assert.assertEquals(geoObj.getValue(testDate.getName()), result.getValue(testDate.getName()));
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Calendar(java.util.Calendar) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Test(org.junit.Test)

Example 99 with LocalizedValue

use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.

the class BusinessTypeTest method testGetAttribute.

@Test
@Request
public void testGetAttribute() {
    String code = "TEST_PROG";
    String orgCode = FastTestDataset.ORG_CGOV.getCode();
    String label = "Test Prog";
    JsonObject object = new JsonObject();
    object.addProperty(BusinessType.CODE, code);
    object.addProperty(BusinessType.ORGANIZATION, orgCode);
    object.add(BusinessType.DISPLAYLABEL, new LocalizedValue(label).toJSON());
    BusinessType type = BusinessType.apply(object);
    try {
        AttributeCharacterType expected = new AttributeCharacterType("testCharacter", new LocalizedValue("Test Character"), new LocalizedValue("Test True"), false, false, false);
        type.createAttributeType(expected);
        AttributeType actual = type.getAttribute(expected.getName());
        Assert.assertTrue(actual instanceof AttributeCharacterType);
        Assert.assertEquals(expected.getName(), actual.getName());
        Assert.assertEquals(expected.getLabel().getValue(), actual.getLabel().getValue());
        Assert.assertEquals(expected.getIsDefault(), actual.getIsDefault());
    } finally {
        type.delete();
    }
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) BusinessType(net.geoprism.registry.BusinessType) JsonObject(com.google.gson.JsonObject) AttributeCharacterType(org.commongeoregistry.adapter.metadata.AttributeCharacterType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 100 with LocalizedValue

use of org.commongeoregistry.adapter.dataaccess.LocalizedValue in project geoprism-registry by terraframe.

the class ExcelServiceTest method classSetUp.

@BeforeClass
@Request
public static void classSetUp() {
    type = ClassificationType.apply(ClassificationTypeTest.createMock());
    Classification root = Classification.newInstance(type);
    root.setCode(CODE);
    root.setDisplayLabel(new LocalizedValue("Test Classification"));
    root.apply(null);
    TestDataSet.deleteAllSchedulerData();
    testData = USATestData.newTestData();
    testData.setUpMetadata();
    testTerm = (AttributeTermType) TestDataSet.createTermAttribute("testTerm", "testTermLocalName", USATestData.DISTRICT, null).fetchDTO();
    testBoolean = (AttributeBooleanType) TestDataSet.createAttribute("testBoolean", "testBooleanLocalName", USATestData.DISTRICT, AttributeBooleanType.TYPE).fetchDTO();
    testDate = (AttributeDateType) TestDataSet.createAttribute("testDate", "testDateLocalName", USATestData.DISTRICT, AttributeDateType.TYPE).fetchDTO();
    testInteger = (AttributeIntegerType) TestDataSet.createAttribute("testInteger", "testIntegerLocalName", USATestData.DISTRICT, AttributeIntegerType.TYPE).fetchDTO();
    if (!SchedulerManager.initialized()) {
        SchedulerManager.start();
    }
    testClassification = (AttributeClassificationType) AttributeType.factory("testClassification", new LocalizedValue("testClassificationLocalName"), new LocalizedValue("testClassificationLocalDescrip"), AttributeClassificationType.TYPE, false, false, false);
    testClassification.setClassificationType(type.getCode());
    testClassification.setRootTerm(root.toTerm());
    ServerGeoObjectType got = ServerGeoObjectType.get(USATestData.DISTRICT.getCode());
    testClassification = (AttributeClassificationType) got.createAttributeType(testClassification.toJSON().toString());
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AbstractClassification(com.runwaysdk.system.AbstractClassification) Classification(net.geoprism.registry.model.Classification) BeforeClass(org.junit.BeforeClass) Request(com.runwaysdk.session.Request)

Aggregations

LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)133 Request (com.runwaysdk.session.Request)54 Test (org.junit.Test)52 JsonObject (com.google.gson.JsonObject)27 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)22 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)16 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)16 Term (org.commongeoregistry.adapter.Term)15 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)15 Date (java.util.Date)13 Locale (java.util.Locale)13 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)13 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)13 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)11 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)11 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)10 JsonArray (com.google.gson.JsonArray)9 Classification (net.geoprism.registry.model.Classification)9 VertexObject (com.runwaysdk.business.graph.VertexObject)7