Search in sources :

Example 1 with ServerGeoObjectType

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

the class HierarchicalRelationshipType method getChildren.

public List<ServerGeoObjectType> getChildren(ServerGeoObjectType parent) {
    Universal universal = parent.getUniversal();
    List<ServerGeoObjectType> children = new LinkedList<>();
    String mdRelationshipType = this.getMdTermRelationship().definesType();
    try (OIterator<? extends Business> iterator = universal.getDirectDescendants(mdRelationshipType)) {
        while (iterator.hasNext()) {
            Universal cUniversal = (Universal) iterator.next();
            children.add(ServerGeoObjectType.get(cUniversal));
        }
    }
    return children;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList)

Example 2 with ServerGeoObjectType

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

the class IncrementalListType method createEntries.

@Override
@Transaction
public void createEntries(JsonObject metadata) {
    if (!this.isValid()) {
        throw new InvalidMasterListException();
    }
    final ServerGeoObjectType objectType = this.getGeoObjectType();
    Pair<Date, Date> range = this.getDateRange(objectType);
    if (metadata == null) {
        List<ListTypeEntry> entries = this.getEntries();
        if (entries.size() > 0) {
            ListTypeEntry entry = entries.get(0);
            ListTypeVersion working = entry.getWorking();
            metadata = working.toJSON(false);
        }
    }
    if (range != null) {
        Date endDate = range.getSecond();
        if (endDate.after(new Date())) {
            endDate = new Date();
        }
        List<Date> dates = this.getFrequencyDates(range.getFirst(), range.getSecond());
        for (Date date : dates) {
            this.getOrCreateEntry(date, metadata);
        }
    } else {
        throw new EmptyListException();
    }
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with ServerGeoObjectType

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

the class ListType method toJSON.

public JsonObject toJSON(boolean includeEntries) {
    Locale locale = Session.getCurrentLocale();
    LocaleSerializer serializer = new LocaleSerializer(locale);
    ServerGeoObjectType type = ServerGeoObjectType.get(this.getUniversal());
    ServerGeoObjectType superType = type.getSuperType();
    Organization org = type.getOrganization();
    JsonObject object = new JsonObject();
    if (this.isAppliedToDB()) {
        object.addProperty(ListType.OID, this.getOid());
    }
    object.addProperty(ListType.ORGANIZATION, org.getCode());
    object.addProperty("write", this.doesActorHaveWritePermission());
    object.addProperty("read", this.doesActorHaveReadPermission());
    object.addProperty("exploratory", this.doesActorHaveExploratoryPermission());
    object.addProperty("typeLabel", type.getLabel().getValue());
    object.addProperty("typePrivate", type.getIsPrivate());
    object.addProperty(ListType.TYPE_CODE, type.getCode());
    object.add(ListType.DISPLAYLABEL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisplayLabel()).toJSON(serializer));
    object.add(ListType.DESCRIPTION, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescription()).toJSON(serializer));
    object.addProperty(ListType.CODE, this.getCode());
    object.add(ListType.HIERARCHIES, this.getHierarchiesAsJson());
    object.add(ListType.SUBTYPEHIERARCHIES, this.getSubtypeHierarchiesAsJson());
    if (this.getFilterJson() != null && this.getFilterJson().length() > 0) {
        object.add(ListType.FILTER, JsonParser.parseString(this.getFilterJson()).getAsJsonArray());
    }
    if (type.getGeometryType().equals(GeometryType.MULTIPOINT) || type.getGeometryType().equals(GeometryType.POINT)) {
        object.addProperty(ListType.INCLUDELATLONG, this.getIncludeLatLong());
    }
    if (superType != null) {
        object.addProperty("superTypeCode", superType.getCode());
    }
    // Include the list metadata
    object.add(ListType.LIST_METADATA, this.toMetadataJSON("list", serializer));
    object.add(ListType.GEOSPATIAL_METADATA, this.toMetadataJSON("geospatial", serializer));
    if (includeEntries) {
        List<ListTypeEntry> entries = this.getEntries();
        JsonArray jEntries = new JsonArray();
        for (ListTypeEntry entry : entries) {
            jEntries.add(entry.toJSON());
        }
        object.add("entries", jEntries);
    }
    return object;
}
Also used : Locale(java.util.Locale) JsonArray(com.google.gson.JsonArray) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LocaleSerializer(net.geoprism.registry.service.LocaleSerializer) JsonObject(com.google.gson.JsonObject)

Example 4 with ServerGeoObjectType

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

the class ListType method listForType.

public static JsonObject listForType(String typeCode) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    Organization org = type.getOrganization();
    final boolean isMember = Organization.isMember(org);
    ListTypeQuery query = new ListTypeQuery(new QueryFactory());
    query.WHERE(query.getUniversal().EQ(type.getUniversal()));
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    final JsonArray lists = new JsonArray();
    try (OIterator<? extends ListType> it = query.getIterator()) {
        it.getAll().stream().sorted((a, b) -> {
            return a.getDisplayLabel().getValue().compareTo(b.getDisplayLabel().getValue());
        }).filter(f -> {
            return true;
        }).forEach(list -> {
            // JsonObject object = new JsonObject();
            // object.addProperty("label", list.getDisplayLabel().getValue());
            // object.addProperty("oid", list.getOid());
            // object.addProperty("createDate",
            // format.format(list.getCreateDate()));
            // object.addProperty("lasteUpdateDate",
            // format.format(list.getLastUpdateDate()));
            // object.addProperty("write", list.doesActorHaveWritePermission());
            // object.addProperty("read", list.doesActorHaveReadPermission());
            // 
            lists.add(list.toJSON());
        });
    }
    JsonObject object = new JsonObject();
    object.addProperty("orgCode", org.getCode());
    object.addProperty("orgLabel", org.getDisplayLabel().getValue());
    object.addProperty("typeCode", type.getCode());
    object.addProperty("typeLabel", type.getLabel().getValue());
    object.addProperty("geometryType", type.getGeometryType().name());
    object.addProperty("write", doesActorHaveWritePermissions(type));
    object.add("lists", lists);
    return object;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) Operation(com.runwaysdk.business.rbac.Operation) Date(java.util.Date) Authenticate(com.runwaysdk.business.rbac.Authenticate) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) CreateListPermissionException(net.geoprism.registry.roles.CreateListPermissionException) MdAttributeDateTimeUtil(com.runwaysdk.constants.MdAttributeDateTimeUtil) ClassificationType(net.geoprism.registry.model.ClassificationType) Locale(java.util.Locale) Map(java.util.Map) AttributeBooleanType(org.commongeoregistry.adapter.metadata.AttributeBooleanType) TermConverter(net.geoprism.registry.conversion.TermConverter) UpdateListPermissionException(net.geoprism.registry.roles.UpdateListPermissionException) Optional(org.commongeoregistry.adapter.Optional) Collection(java.util.Collection) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) List(java.util.List) JsonArray(com.google.gson.JsonArray) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) GeometryType(org.commongeoregistry.adapter.constants.GeometryType) CompositeRestriction(net.geoprism.registry.query.graph.CompositeRestriction) Universal(com.runwaysdk.system.gis.geo.Universal) ListTypeJob(net.geoprism.registry.etl.ListTypeJob) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) GeoprismProperties(net.geoprism.GeoprismProperties) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) JsonParser(com.google.gson.JsonParser) Constants(com.runwaysdk.constants.Constants) ServiceFactory(net.geoprism.registry.service.ServiceFactory) Classifier(net.geoprism.ontology.Classifier) LocalizationFacade(com.runwaysdk.localization.LocalizationFacade) ListTypeJobQuery(net.geoprism.registry.etl.ListTypeJobQuery) Classification(net.geoprism.registry.model.Classification) AttributeValueRestriction(net.geoprism.registry.query.graph.AttributeValueRestriction) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) QueryFactory(com.runwaysdk.query.QueryFactory) LinkedList(java.util.LinkedList) LocalStruct(com.runwaysdk.business.LocalStruct) MdClassificationDAOIF(com.runwaysdk.dataaccess.MdClassificationDAOIF) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Term(org.commongeoregistry.adapter.Term) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) AttributeDateType(org.commongeoregistry.adapter.metadata.AttributeDateType) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) OR(com.runwaysdk.query.OR) File(java.io.File) OIterator(com.runwaysdk.query.OIterator) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) BasicVertexRestriction(net.geoprism.registry.query.graph.BasicVertexRestriction) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) Session(com.runwaysdk.session.Session) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) LocaleSerializer(net.geoprism.registry.service.LocaleSerializer) QueryFactory(com.runwaysdk.query.QueryFactory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with ServerGeoObjectType

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

the class ListType method markAsInvalid.

public void markAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
    boolean isValid = true;
    JsonArray hierarchies = this.getHierarchiesAsJson();
    ServerGeoObjectType masterlistType = this.getGeoObjectType();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        String hCode = hierarchy.get("code").getAsString();
        Optional<ServerHierarchyType> ht = ServiceFactory.getMetadataCache().getHierachyType(hCode);
        if (ht.isPresent()) {
            ServerHierarchyType actualHierarchy = masterlistType.findHierarchy(ht.get(), type);
            if (hCode.equals(hierarchyType.getCode()) || actualHierarchy.getCode().equals(hierarchyType.getCode())) {
                List<String> pCodes = this.getParentCodes(hierarchy);
                if (pCodes.contains(type.getCode()) || type.getCode().equals(masterlistType.getCode())) {
                    isValid = false;
                }
            }
        } else {
            isValid = false;
        }
    }
    if (!isValid) {
        this.appLock();
        this.setValid(false);
        this.apply();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject)

Aggregations

ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)201 Request (com.runwaysdk.session.Request)69 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)57 JsonObject (com.google.gson.JsonObject)48 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)32 JsonArray (com.google.gson.JsonArray)30 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)30 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)27 LinkedList (java.util.LinkedList)27 Test (org.junit.Test)27 VertexObject (com.runwaysdk.business.graph.VertexObject)26 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)26 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)23 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)23 Date (java.util.Date)21 GraphQuery (com.runwaysdk.business.graph.GraphQuery)19 List (java.util.List)18 EdgeObject (com.runwaysdk.business.graph.EdgeObject)17 SimpleDateFormat (java.text.SimpleDateFormat)17 Locale (java.util.Locale)17