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;
}
}
}
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;
}
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();
}
}
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;
}
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;
}
}
Aggregations