Search in sources :

Example 56 with ServerGeoObjectIF

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

the class MasterListVersion method publishNoAuth.

@Transaction
public String publishNoAuth() {
    this.lock();
    try {
        MasterList masterlist = this.getMasterlist();
        if (!masterlist.isValid()) {
            throw new InvalidMasterListException();
        }
        // Delete tile cache
        TileCache.deleteTiles(this);
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        mdBusiness.deleteAllRecords();
        MdAttributeConcreteDAO status = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("status");
        if (status != null) {
            MasterListAttributeGroup.remove(status);
            status.delete();
        }
        MdAttributeConcreteDAO statusDefaultLocale = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("statusDefaultLocale");
        if (statusDefaultLocale != null) {
            MasterListAttributeGroup.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());
        VertexGeoObjectQuery query = new VertexGeoObjectQuery(type, this.getForDate());
        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 VertexGeoObjectQuery(type, this.getForDate());
                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(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) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Date(java.util.Date) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) VertexGeoObjectQuery(net.geoprism.registry.query.graph.VertexGeoObjectQuery) 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 57 with ServerGeoObjectIF

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

the class CreateGeoObjectAction method execute.

@Override
public void execute() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.apply(geoObject, true, false);
    ServerGeoObjectIF child = service.getGeoObjectByCode(geoObject.getCode(), geoObject.getType().getCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getParentJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 58 with ServerGeoObjectIF

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

the class SetParentAction method execute.

@Override
public void execute() {
    ServerGeoObjectService service = new ServerGeoObjectService();
    ServerGeoObjectIF child = service.getGeoObjectByCode(this.getChildCode(), this.getChildTypeCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 59 with ServerGeoObjectIF

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

the class AddChildAction method execute.

@Override
public void execute() {
    ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
    ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
    ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
    ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(), parent.getType(), child.getType());
    parent.addChild(child, ht);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService)

Example 60 with ServerGeoObjectIF

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

the class ChangeRequestTestDataGenerator method genChangeRequest.

@Transaction
private static void genChangeRequest(String genKey, Instant when, boolean includeRemove, boolean includeAdd) {
    ServerGeoObjectService service = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService());
    GeoObject goNewChild = ServiceFactory.getAdapter().newGeoObjectInstance("Cambodia_District");
    goNewChild.setCode(genKey + "_CODE");
    goNewChild.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, genKey + "_LABEL");
    goNewChild.setWKTGeometry("MULTIPOLYGON (((10000 10000, 12300 40000, 16800 50000, 12354 60000, 13354 60000, 17800 50000, 13300 40000, 11000 10000, 10000 10000)))");
    ServerGeoObjectIF testAddChildParent = service.getGeoObjectByCode("855 01", "Cambodia_Province");
    ServerGeoObjectIF testAddChild = service.getGeoObjectByCode("855 0109", "Cambodia_District");
    List<AbstractActionDTO> actions = new ArrayList<AbstractActionDTO>();
    /*
     * Remove Child
     */
    if (includeRemove) {
        RemoveChildActionDTO removeChild = new RemoveChildActionDTO();
        removeChild.setChildCode(testAddChild.getUid());
        removeChild.setChildTypeCode(testAddChild.getType().getCode());
        removeChild.setParentCode(testAddChildParent.getUid());
        removeChild.setParentTypeCode(testAddChildParent.getType().getCode());
        removeChild.setHierarchyCode(LocatedIn.class.getSimpleName());
        removeChild.setCreateActionDate(Date.from(when.minus(9, ChronoUnit.HOURS)));
        removeChild.setContributorNotes("Removing the village from the district");
        actions.add(removeChild);
    }
    /*
     * Add Child
     */
    if (includeAdd) {
        AddChildActionDTO addChild = new AddChildActionDTO();
        addChild.setChildCode(testAddChild.getUid());
        addChild.setChildTypeCode(testAddChild.getType().getCode());
        addChild.setParentCode(testAddChildParent.getUid());
        addChild.setParentTypeCode(testAddChildParent.getType().getCode());
        addChild.setHierarchyCode(LocatedIn.class.getSimpleName());
        addChild.setCreateActionDate(Date.from(when.minus(10, ChronoUnit.HOURS)));
        addChild.setContributorNotes("Adding the village as a child of the district");
        actions.add(addChild);
    }
    /*
     * Create a new GeoObject
     */
    CreateGeoObjectActionDTO create = new CreateGeoObjectActionDTO();
    create.setGeoObject(goNewChild.toJSON());
    create.setCreateActionDate(Date.from(when.minus(8, ChronoUnit.HOURS)));
    create.setContributorNotes("Creating a new village");
    actions.add(create);
    /*
     * Update the previously created GeoObject
     */
    final String NEW_DISPLAY_LABEL = genKey + "_NEW_DISPLAY_LABEL";
    goNewChild.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, NEW_DISPLAY_LABEL);
    UpdateGeoObjectActionDTO update = new UpdateGeoObjectActionDTO();
    update.setGeoObject(goNewChild.toJSON());
    update.setCreateActionDate(Date.from(when.minus(7, ChronoUnit.HOURS)));
    update.setContributorNotes("Updating the village. Adding a better name and stuff");
    actions.add(update);
    // Serialize the actions
    String sActions = AbstractActionDTO.serializeActions(actions).toString();
    submitChangeRequest(sActions);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) RemoveChildActionDTO(org.commongeoregistry.adapter.action.tree.RemoveChildActionDTO) UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) LocatedIn(com.runwaysdk.system.gis.geo.LocatedIn) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ArrayList(java.util.ArrayList) AbstractActionDTO(org.commongeoregistry.adapter.action.AbstractActionDTO) AddChildActionDTO(org.commongeoregistry.adapter.action.tree.AddChildActionDTO) CreateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.CreateGeoObjectActionDTO) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService) 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