Search in sources :

Example 96 with ServerGeoObjectType

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

the class ListType method markAsInvalid.

public void markAsInvalid(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()) {
            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)

Example 97 with ServerGeoObjectType

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

the class ListType method parse.

protected void parse(JsonObject object) {
    String typeCode = object.get(ListType.TYPE_CODE).getAsString();
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    this.setUniversal(type.getUniversal());
    LocalizedValueConverter.populate(this.getDisplayLabel(), LocalizedValue.fromJSON(object.get(ListType.DISPLAYLABEL).getAsJsonObject()));
    LocalizedValueConverter.populate(this.getDescription(), LocalizedValue.fromJSON(object.get(ListType.DESCRIPTION).getAsJsonObject()));
    this.setCode(object.get(ListType.CODE).getAsString());
    this.setHierarchies(object.get(ListType.HIERARCHIES).getAsJsonArray().toString());
    this.setOrganization(Organization.getByCode(object.get(ListType.ORGANIZATION).getAsString()));
    if (object.has(ListType.INCLUDELATLONG)) {
        this.setIncludeLatLong(object.get(ListType.INCLUDELATLONG).getAsBoolean());
    }
    if (object.has(ListType.SUBTYPEHIERARCHIES) && !object.get(ListType.SUBTYPEHIERARCHIES).isJsonNull()) {
        this.setSubtypeHierarchies(object.get(ListType.SUBTYPEHIERARCHIES).getAsJsonArray().toString());
    }
    if (object.has(ListType.FILTER) && !object.get(ListType.FILTER).isJsonNull()) {
        this.setFilterJson(object.get(ListType.FILTER).getAsJsonArray().toString());
    }
// Parse the list metadata
// this.parseMetadata("list", object.get(LIST_METADATA).getAsJsonObject());
// this.parseMetadata("geospatial",
// object.get(GEOSPATIAL_METADATA).getAsJsonObject());
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType)

Example 98 with ServerGeoObjectType

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

the class ListType method getAncestorMap.

public Map<ServerHierarchyType, List<ServerGeoObjectType>> getAncestorMap(ServerGeoObjectType type) {
    Map<ServerHierarchyType, List<ServerGeoObjectType>> map = new HashMap<>();
    JsonArray hierarchies = this.getHierarchiesAsJson();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        List<String> pCodes = this.getParentCodes(hierarchy);
        if (pCodes.size() > 0) {
            String hCode = hierarchy.get("code").getAsString();
            ServerHierarchyType hierarchyType = ServerHierarchyType.get(hCode);
            List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
            List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
            for (GeoObjectType ancestor : dtoAncestors) {
                ancestors.add(ServerGeoObjectType.get(ancestor));
            }
            map.put(hierarchyType, ancestors);
        }
    }
    return map;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) LinkedList(java.util.LinkedList) JsonArray(com.google.gson.JsonArray) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) List(java.util.List) LinkedList(java.util.LinkedList)

Example 99 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType 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)

Example 100 with ServerGeoObjectType

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

the class MasterList method toJSON.

public JsonObject toJSON(String versionType) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Locale locale = Session.getCurrentLocale();
    LocaleSerializer serializer = new LocaleSerializer(locale);
    ServerGeoObjectType type = ServerGeoObjectType.get(this.getUniversal());
    JsonObject object = new JsonObject();
    if (this.isAppliedToDB()) {
        final Organization org = this.getOrganization();
        object.addProperty(MasterList.OID, this.getOid());
        object.addProperty(MasterList.ORGANIZATION, org.getOid());
    } else {
        object.addProperty(MasterList.ORGANIZATION, this.getOrganizationOid());
    }
    object.addProperty("write", this.doesActorHaveWritePermission());
    object.addProperty("read", this.doesActorHaveReadPermission());
    object.addProperty("exploratory", this.doesActorHaveExploratoryPermission());
    object.add("typeLabel", type.getLabel().toJSON(serializer));
    object.addProperty(MasterList.TYPE_CODE, type.getCode());
    object.add(MasterList.DISPLAYLABEL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisplayLabel()).toJSON(serializer));
    object.addProperty(MasterList.CODE, this.getCode());
    object.add(MasterList.DESCRIPTIONLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescriptionLocal()).toJSON(serializer));
    object.add(MasterList.DESCRIPTIONLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescriptionLocal()).toJSON(serializer));
    object.add(MasterList.PROCESSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getProcessLocal()).toJSON(serializer));
    object.add(MasterList.PROGRESSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getProgressLocal()).toJSON(serializer));
    object.add(MasterList.ACCESSCONSTRAINTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getAccessConstraintsLocal()).toJSON(serializer));
    object.add(MasterList.USECONSTRAINTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getUseConstraintsLocal()).toJSON(serializer));
    object.add(MasterList.ACKNOWLEDGEMENTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getAcknowledgementsLocal()).toJSON(serializer));
    object.add(MasterList.DISCLAIMERLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisclaimerLocal()).toJSON(serializer));
    object.addProperty(MasterList.CONTACTNAME, this.getContactName());
    object.addProperty(MasterList.TELEPHONENUMBER, this.getTelephoneNumber());
    object.addProperty(MasterList.EMAIL, this.getEmail());
    object.addProperty(MasterList.FREQUENCY, this.toFrequency().name());
    object.addProperty(MasterList.ISMASTER, this.getIsMaster());
    object.addProperty(MasterList.VISIBILITY, this.getVisibility());
    object.add(MasterList.HIERARCHIES, this.getHierarchiesAsJson());
    object.add(MasterList.SUBTYPEHIERARCHIES, this.getSubtypeHierarchiesAsJson());
    if (this.getPublishingStartDate() != null) {
        object.addProperty(MasterList.PUBLISHINGSTARTDATE, format.format(this.getPublishingStartDate()));
    }
    if (this.getRepresentativityDate() != null) {
        object.addProperty(MasterList.REPRESENTATIVITYDATE, format.format(this.getRepresentativityDate()));
    }
    if (this.getPublishDate() != null) {
        object.addProperty(MasterList.PUBLISHDATE, format.format(this.getPublishDate()));
    }
    if (versionType != null) {
        List<MasterListVersion> versions = this.getVersions(versionType);
        JsonArray jVersions = new JsonArray();
        for (MasterListVersion version : versions) {
            jVersions.add(version.toJSON(false));
        }
        object.add(MasterList.VERSIONS, jVersions);
    }
    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) SimpleDateFormat(java.text.SimpleDateFormat)

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