use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class ChangeRequest method getGeoObjectDisplayLabel.
public LocalizedValue getGeoObjectDisplayLabel() {
if (this.getChangeRequestType().equals(ChangeRequestType.CreateGeoObject)) {
try {
GeoObjectOverTime goTime = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), ((CreateGeoObjectAction) this.getAllAction().next()).getGeoObjectJson());
// Quick little hack to localize a value when it's not in a database or part of a Runway object.
LocalizedValueStore lvs = new LocalizedValueStore();
lvs.getStoreValue().setLocaleMap(goTime.getDisplayLabel(new Date()).getLocaleMap());
return LocalizedValueConverter.convertNoAutoCoalesce(lvs.getStoreValue());
} catch (Exception e) {
logger.error("Error occurred while getting localized label from GeoObject with code [" + this.getGeoObjectCode() + "].", e);
}
} else {
ServerGeoObjectIF serverGO = new ServerGeoObjectService().getGeoObjectByCode(this.getGeoObjectCode(), this.getGeoObjectTypeCode(), false);
if (serverGO != null) {
return serverGO.getDisplayLabel();
}
}
LocalizedValue lv = new LocalizedValue(this.getGeoObjectCode());
lv.setValue(LocalizedValue.DEFAULT_LOCALE, this.getGeoObjectCode());
return lv;
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class AddChildAction method apply.
@Override
public void apply() {
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().enforceCanAddChildCR(ht.getOrganization().getCode(), parent.getType(), child.getType());
super.apply();
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class RemoveChildAction method apply.
@Override
public void apply() {
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().enforceCanRemoveChildCR(ht.getOrganization().getCode(), parent.getType(), child.getType());
super.apply();
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class RemoveChildAction 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().enforceCanRemoveChild(ht.getOrganization().getCode(), parent.getType(), child.getType());
parent.removeChild(child, this.getHierarchyTypeCode(), null, null);
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class ETLService method submitImportErrorResolutionInTrans.
@Transaction
private void submitImportErrorResolutionInTrans(String sessionId, String json) {
JsonObject config = JsonParser.parseString(json).getAsJsonObject();
ImportHistory hist = ImportHistory.get(config.get("historyId").getAsString());
hist.getConfig().enforceExecutePermissions();
ImportError err = ImportError.get(config.get("importErrorId").getAsString());
String resolution = config.get("resolution").getAsString();
if (resolution.equals(ErrorResolution.APPLY_GEO_OBJECT.name())) {
String parentTreeNode = config.get("parentTreeNode").toString();
String geoObject = config.get("geoObject").toString();
Boolean isNew = config.get("isNew").getAsBoolean();
GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), geoObject);
if (isNew) {
go.setUid(RegistryIdService.getInstance().next());
geoObject = go.toJSON().toString();
new ServerGeoObjectService().createGeoObject(sessionId, parentTreeNode, geoObject, null, null);
} else {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF serverGO = service.apply(go, isNew, false);
final ServerGeoObjectType type = serverGO.getType();
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, parentTreeNode);
serverGO.setParents(ptnOt);
}
err.appLock();
err.setResolution(resolution);
err.apply();
hist.appLock();
hist.setErrorResolvedCount(hist.getErrorResolvedCount() + 1);
hist.setImportedRecords(hist.getImportedRecords() + 1);
hist.apply();
} else if (resolution.equals(ErrorResolution.IGNORE.name())) {
err.appLock();
err.setResolution(resolution);
err.apply();
} else {
throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
}
}
Aggregations