Search in sources :

Example 41 with ServerGeoObjectType

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

the class GeoObjectImporter method setClassificationValue.

protected void setClassificationValue(ServerGeoObjectIF entity, AttributeType attributeType, String attributeName, Object value, Date startDate, Date endDate) {
    if (!this.configuration.isExclusion(attributeName, value.toString())) {
        try {
            ServerGeoObjectType type = this.configuration.getType();
            MdBusinessDAOIF mdBusiness = type.getMdBusinessDAO();
            MdAttributeClassificationDAOIF mdAttribute = (MdAttributeClassificationDAOIF) mdBusiness.definesAttribute(attributeName);
            if (mdAttribute == null && type.getSuperType() != null) {
                mdAttribute = (MdAttributeClassificationDAOIF) type.getSuperType().getMdBusinessDAO().definesAttribute(attributeName);
            }
            VertexObject classifier = AbstractClassification.findMatchingClassification(value.toString().trim(), mdAttribute);
            if (classifier == null) {
                throw new UnknownTermException(value.toString().trim(), attributeType);
            // Term rootClassification = ( (AttributeClassificationType) attributeType ).getRootTerm();
            // 
            // TermReferenceProblem trp = new TermReferenceProblem(value.toString(), rootClassification.getCode(), mdAttribute.getOid(), attributeName, attributeType.getLabel().getValue());
            // trp.addAffectedRowNumber(this.progressListener.getWorkProgress() + 1);
            // trp.setHistoryId(this.configuration.getHistoryId());
            // 
            // this.progressListener.addReferenceProblem(trp);
            } else {
                entity.setValue(attributeName, classifier.getOid(), startDate, endDate);
            }
        } catch (UnknownTermException e) {
            TermValueException ex = new TermValueException();
            ex.setAttributeLabel(e.getAttribute().getLabel().getValue());
            ex.setCode(e.getCode());
            throw e;
        }
    }
}
Also used : MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) TermValueException(net.geoprism.registry.io.TermValueException) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeClassificationDAOIF(com.runwaysdk.dataaccess.MdAttributeClassificationDAOIF) UnknownTermException(org.commongeoregistry.adapter.dataaccess.UnknownTermException)

Example 42 with ServerGeoObjectType

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

the class GeoObjectExcelExporter method createWorkbook.

public Workbook createWorkbook() throws IOException {
    Workbook workbook = new XSSFWorkbook();
    Sheet sheet = workbook.createSheet(WorkbookUtil.createSafeSheetName(this.type.getLabel().getValue()));
    CreationHelper createHelper = workbook.getCreationHelper();
    Font font = workbook.createFont();
    font.setBold(true);
    CellStyle boldStyle = workbook.createCellStyle();
    boldStyle.setFont(font);
    CellStyle dateStyle = workbook.createCellStyle();
    dateStyle.setDataFormat(createHelper.createDataFormat().getFormat(BuiltinFormats.getBuiltinFormat(14)));
    Row header = sheet.createRow(0);
    boolean includeCoordinates = this.type.getGeometryType().equals(GeometryType.POINT) || this.type.getGeometryType().equals(GeometryType.MIXED);
    Collection<AttributeType> attributes = new ImportAttributeSerializer(Session.getCurrentLocale(), includeCoordinates, true, locales).attributes(this.type.getType());
    // Get the ancestors of the type
    List<GeoObjectType> dtoAncestors = this.type.getTypeAncestors(this.hierarchy, true);
    List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
    for (GeoObjectType ancestor : dtoAncestors) {
        ancestors.add(ServerGeoObjectType.get(ancestor));
    }
    this.writeHeader(boldStyle, header, attributes, ancestors);
    for (int i = 0; i < this.objects.size(); i++) {
        ServerGeoObjectIF object = this.objects.get(i);
        Row row = sheet.createRow(i + 1);
        this.writeRow(row, object, attributes, ancestors, dateStyle);
    }
    return workbook;
}
Also used : ImportAttributeSerializer(net.geoprism.registry.io.ImportAttributeSerializer) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) CreationHelper(org.apache.poi.ss.usermodel.CreationHelper) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) Font(org.apache.poi.ss.usermodel.Font) LinkedList(java.util.LinkedList) Point(com.vividsolutions.jts.geom.Point) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) CellStyle(org.apache.poi.ss.usermodel.CellStyle) Row(org.apache.poi.ss.usermodel.Row) Sheet(org.apache.poi.ss.usermodel.Sheet)

Example 43 with ServerGeoObjectType

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

the class ServerGeoObjectService method createGeoObjectInTrans.

@Transaction
public JsonObject createGeoObjectInTrans(String sPtn, String sTimeGo, String masterListId, String notes) {
    GeoObjectOverTime timeGO = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sTimeGo);
    ServerGeoObjectType serverGOT = ServerGeoObjectType.get(timeGO.getType());
    RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final String orgCode = serverGOT.getOrganization().getCode();
    if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT)) {
        ServerGeoObjectService service = new ServerGeoObjectService();
        ServerGeoObjectIF serverGO = service.apply(timeGO, true, false);
        final ServerGeoObjectType type = serverGO.getType();
        if (sPtn != null) {
            ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, sPtn);
            serverGO.setParents(ptnOt);
        }
        // Update the master list record
        if (masterListId != null) {
            ListTypeVersion.get(masterListId).publishRecord(serverGO);
        }
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", false);
        resp.add("geoObject", serverGO.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
        return resp;
    } else if (ServiceFactory.getRolePermissionService().isRC(orgCode, serverGOT)) {
        Instant base = Instant.now();
        int sequence = 0;
        ChangeRequest request = new ChangeRequest();
        request.addApprovalStatus(AllGovernanceStatus.PENDING);
        request.setContributorNotes(notes);
        request.setGeoObjectCode(timeGO.getCode());
        request.setGeoObjectTypeCode(timeGO.getType().getCode());
        request.setOrganizationCode(orgCode);
        request.apply();
        CreateGeoObjectAction action = new CreateGeoObjectAction();
        action.addApprovalStatus(AllGovernanceStatus.PENDING);
        action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
        action.setGeoObjectJson(sTimeGo);
        action.setParentJson(sPtn);
        action.setApiVersion(CGRAdapterProperties.getApiVersion());
        action.setContributorNotes(notes);
        action.apply();
        request.addAction(action).apply();
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", true);
        resp.addProperty("changeRequestId", request.getOid());
        return resp;
    } else {
        throw new CGRPermissionException();
    }
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) CGRPermissionException(net.geoprism.registry.CGRPermissionException) CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Instant(java.time.Instant) JsonObject(com.google.gson.JsonObject) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 44 with ServerGeoObjectType

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

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(String uid, String typeCode) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    ServerGeoObjectIF object = strategy.getGeoObjectByUid(uid);
    if (object == null) {
        InvalidRegistryIdException ex = new InvalidRegistryIdException();
        ex.setRegistryId(uid);
        throw ex;
    }
    return object;
}
Also used : InvalidRegistryIdException(net.geoprism.registry.InvalidRegistryIdException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 45 with ServerGeoObjectType

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

the class ServerGeoObjectService method apply.

@Transaction
public ServerGeoObjectIF apply(GeoObject object, Date startDate, Date endDate, boolean isNew, boolean isImport) {
    ServerGeoObjectType type = ServerGeoObjectType.get(object.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    if (isNew) {
        permissionService.enforceCanCreate(type.getOrganization().getCode(), type);
    } else {
        permissionService.enforceCanWrite(type.getOrganization().getCode(), type);
    }
    ServerGeoObjectIF geoObject = strategy.constructFromGeoObject(object, isNew);
    geoObject.setDate(startDate);
    if (!isNew) {
        geoObject.lock();
    }
    geoObject.populate(object, startDate, endDate);
    try {
        geoObject.apply(isImport);
        // Return the refreshed copy of the geoObject
        return this.build(type, geoObject.getRunwayId());
    } catch (DuplicateDataException e) {
        VertexServerGeoObject.handleDuplicateDataException(type, e);
        throw e;
    }
}
Also used : DuplicateDataException(com.runwaysdk.dataaccess.DuplicateDataException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

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