use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class UpdateParentValueOverTimeView method getNewValueAsGO.
public VertexServerGeoObject getNewValueAsGO() {
if (this.newValue != null && !this.newValue.isJsonNull()) {
String[] newValueSplit = (this.getNewValue().getAsString()).split(VALUE_SPLIT_TOKEN);
String parentTypeCode = newValueSplit[0];
String parentCode = newValueSplit[1];
ServerGeoObjectType parentType = ServerGeoObjectType.get(parentTypeCode);
final VertexServerGeoObject parent = new VertexGeoObjectStrategy(parentType).getGeoObjectByCode(parentCode);
return parent;
}
return null;
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class UpdateValueOverTimeView method persistValue.
private void persistValue(ValueOverTime vot, UpdateChangeOverTimeAttributeView cotView, VertexServerGeoObject go, List<ValueOverTime> looseVotc) {
if (this.newValue == null) {
return;
}
if (cotView.getAttributeName().equals("geometry")) {
Geometry convertedValue = null;
if (!this.newValue.isJsonNull()) {
GeoJSONReader reader = new GeoJSONReader();
convertedValue = reader.read(this.newValue.toString());
if (!go.isValidGeometry(convertedValue)) {
GeometryTypeException ex = new GeometryTypeException();
ex.setActualType(convertedValue.getGeometryType());
ex.setExpectedType(go.getType().getGeometryType().name());
throw ex;
}
}
if (vot != null) {
vot.setValue(convertedValue);
} else {
looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, convertedValue));
}
} else {
ServerGeoObjectType type = go.getType();
AttributeType attype = type.getAttribute(cotView.getAttributeName()).get();
if (attype instanceof AttributeLocalType) {
LocalizedValue convertedValue = null;
if (!this.newValue.isJsonNull()) {
convertedValue = LocalizedValue.fromJSON(this.newValue.getAsJsonObject());
}
final Set<Locale> locales = LocalizationFacade.getInstalledLocales();
if (vot != null) {
if (convertedValue != null) {
GraphObjectDAO votEmbeddedValue = (GraphObjectDAO) vot.getValue();
votEmbeddedValue.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, convertedValue.getValue(MdAttributeLocalInfo.DEFAULT_LOCALE));
for (Locale locale : locales) {
if (convertedValue.contains(locale)) {
votEmbeddedValue.setValue(locale.toString(), convertedValue.getValue(locale));
}
}
} else {
vot.setValue(null);
}
} else {
if (convertedValue != null) {
MdAttributeEmbeddedDAOIF mdAttrEmbedded = (MdAttributeEmbeddedDAOIF) go.getMdAttributeDAO(attype.getName());
VertexObjectDAO votEmbeddedValue = VertexObjectDAO.newInstance((MdVertexDAOIF) mdAttrEmbedded.getEmbeddedMdClassDAOIF());
votEmbeddedValue.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, convertedValue.getValue(MdAttributeLocalInfo.DEFAULT_LOCALE));
for (Locale locale : locales) {
if (convertedValue.contains(locale)) {
votEmbeddedValue.setValue(locale.toString(), convertedValue.getValue(locale));
}
}
looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, votEmbeddedValue));
} else {
looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, null));
}
}
} else // else if (attype.getName().equals(DefaultAttribute.EXISTS.getName()))
// {
// if (this.newValue.isJsonNull())
// {
// if (vot != null)
// {
// vot.setValue(null);
// }
// else
// {
// looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
// null));
// }
// }
// else
// {
// JsonArray ja = this.newValue.getAsJsonArray();
//
// if (ja.size() > 0)
// {
// String code = ja.get(0).getAsString();
//
// if (code == null || code.length() == 0)
// {
// if (vot != null)
// {
// vot.setValue(null);
// }
// else
// {
// looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
// null));
// }
// }
// else
// {
// Term value = ( (AttributeTermType) attype ).getTermByCode(code).get();
// GeoObjectStatus gos =
// ConversionService.getInstance().termToGeoObjectStatus(value);
//
// if (vot != null)
// {
// vot.setValue(gos.getOid());
// }
// else
// {
// looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate,
// gos.getOid()));
// }
// }
// }
// }
// }
{
Object convertedValue = null;
if (!this.newValue.isJsonNull()) {
if (attype instanceof AttributeDateType) {
long epoch = this.newValue.getAsLong();
convertedValue = new Date(epoch);
} else if (attype instanceof AttributeTermType) {
JsonArray ja = this.newValue.getAsJsonArray();
if (ja.size() > 0) {
String code = ja.get(0).getAsString();
Term root = ((AttributeTermType) attype).getRootTerm();
String parent = TermConverter.buildClassifierKeyFromTermCode(root.getCode());
String classifierKey = Classifier.buildKey(parent, code);
Classifier classifier = Classifier.getByKey(classifierKey);
convertedValue = classifier.getOid();
}
} else if (attype instanceof AttributeClassificationType) {
JsonObject object = this.newValue.getAsJsonObject();
String code = object.get("code").getAsString();
Classification classification = Classification.get((AttributeClassificationType) attype, code);
convertedValue = new AttributeGraphRef.ID(classification.getOid(), classification.getVertex().getRID());
} else if (attype instanceof AttributeBooleanType) {
convertedValue = this.newValue.getAsBoolean();
} else if (attype instanceof AttributeFloatType) {
convertedValue = this.newValue.getAsDouble();
} else if (attype instanceof AttributeIntegerType) {
convertedValue = this.newValue.getAsLong();
} else {
convertedValue = this.newValue.getAsString();
}
}
if (vot != null) {
vot.setValue(convertedValue);
} else {
looseVotc.add(new ValueOverTime(this.newStartDate, this.newEndDate, convertedValue));
}
}
}
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class RelationshipVisualizationService method tree.
@Request(RequestType.SESSION)
public JsonElement tree(String sessionId, Date date, String relationshipType, String graphTypeCode, String geoObjectCode, String geoObjectTypeCode) {
final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
final ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(geoObjectTypeCode).get();
JsonObject view = new JsonObject();
JsonArray jaEdges = new JsonArray();
view.add("edges", jaEdges);
JsonArray jaVerticies = new JsonArray();
view.add("verticies", jaVerticies);
if (typePermissions.canRead(type.getOrganization().getCode(), type, type.getIsPrivate())) {
VertexServerGeoObject rootGo = (VertexServerGeoObject) ServiceFactory.getGeoObjectService().getGeoObjectByCode(geoObjectCode, type);
final GraphType graphType = GraphType.getByCode(relationshipType, graphTypeCode);
jaVerticies.add(serializeVertex(rootGo, (graphType instanceof UndirectedGraphType) ? "PARENT" : "SELECTED"));
Set<String> setEdges = new HashSet<String>();
Set<String> setVerticies = new HashSet<String>();
if (graphType instanceof UndirectedGraphType) {
// get parent and get children return the same thing for an undirected
// graph
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
} else if (graphType instanceof DirectedAcyclicGraphType) {
// Out is children
fetchParentsData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
// In is parents
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
} else {
// Out is children
fetchParentsData(true, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
// In is parents
fetchChildrenData(false, rootGo, graphType, date, jaEdges, jaVerticies, setEdges, setVerticies);
}
}
return view;
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class XMLImporter method createServerGeoObjectType.
private ServerGeoObjectType createServerGeoObjectType(Organization organization, Element elem) {
String code = elem.getAttribute("code");
LocalizedValue label = this.getLabel(elem);
LocalizedValue description = this.getDescription(elem);
String visibility = elem.getAttribute("visibility");
GeometryType geometryType = this.getGeometryType(elem);
boolean isGeometryEditable = this.getIsGeometryEditable(elem);
boolean isAbstract = this.getIsGroup(elem) || (elem.getElementsByTagName("group-item").getLength() > 0);
GeoObjectType type = new GeoObjectType(code, geometryType, label, description, isGeometryEditable, organization.getCode(), adapter);
type.setIsPrivate(this.getIsPrivate(visibility));
type.setIsAbstract(isAbstract);
ServiceFactory.getGeoObjectTypePermissionService().enforceCanCreate(organization.getCode(), type.getIsPrivate());
return new ServerGeoObjectTypeConverter().create(type);
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class XMLImporter method addChildren.
private void addChildren(ServerHierarchyType hierarchy, ServerGeoObjectType parent, Element root) {
NodeList childNodes = root.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node childNode = childNodes.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) childNode;
String code = elem.getAttribute("code");
ServerGeoObjectType child = ServerGeoObjectType.get(code);
hierarchy.addToHierarchy(parent, child, false);
if (root.hasAttribute("extends")) {
String inheritedHierarchyCode = root.getAttribute("extends");
ServerHierarchyType inheritedHierarchy = ServerHierarchyType.get(inheritedHierarchyCode);
child.setInheritedHierarchy(hierarchy, inheritedHierarchy);
}
this.addChildren(hierarchy, child, elem);
}
}
}
Aggregations