use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class HierarchicalRelationshipType method removeFromHierarchy.
@Transaction
public void removeFromHierarchy(ServerGeoObjectType parentType, ServerGeoObjectType childType, boolean migrateChildren) {
Universal parent = parentType.getUniversal();
Universal cUniversal = childType.getUniversal();
removeLink(parent, cUniversal, this.getMdTermRelationship().definesType());
if (migrateChildren) {
TermAndRel[] tnrChildren = TermUtil.getDirectDescendants(cUniversal.getOid(), new String[] { this.getMdTermRelationship().definesType() });
if (parent.getKey().equals(Universal.ROOT) && tnrChildren.length > 1) {
MultipleHierarchyRootsException ex = new MultipleHierarchyRootsException();
throw ex;
}
for (TermAndRel tnrChild : tnrChildren) {
Universal child = (Universal) tnrChild.getTerm();
removeLink(cUniversal, child, this.getMdTermRelationship().definesType());
child.addLink(parent, this.getMdTermRelationship().definesType());
}
}
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class HierarchicalRelationshipType method getChildren.
public List<ServerGeoObjectType> getChildren(ServerGeoObjectType parent) {
Universal universal = parent.getUniversal();
List<ServerGeoObjectType> children = new LinkedList<>();
String mdRelationshipType = this.getMdTermRelationship().definesType();
try (OIterator<? extends Business> iterator = universal.getDirectDescendants(mdRelationshipType)) {
while (iterator.hasNext()) {
Universal cUniversal = (Universal) iterator.next();
children.add(ServerGeoObjectType.get(cUniversal));
}
}
return children;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class Organization method getGeoObjectTypes.
/**
* Return a map of {@link GeoObjectType} codes and labels for this
* {@link Organization}.
*
* @return a map of {@link GeoObjectType} codes and labels for this
* {@link Organization}.
*/
public Map<String, ServerGeoObjectType> getGeoObjectTypes() {
// For performance, get all of the universals defined
List<? extends EntityDAOIF> universalList = ObjectCache.getCachedEntityDAOs(Universal.CLASS);
Map<String, ServerGeoObjectType> typeCodeMap = new HashMap<String, ServerGeoObjectType>();
for (EntityDAOIF entityDAOIF : universalList) {
Universal universal = (Universal) BusinessFacade.get(entityDAOIF);
// Check to see if the universal is owned by the organization role.
String ownerId = universal.getOwnerOid();
Roles organizationRole = this.getRole();
if (ownerId.equals(organizationRole.getOid())) {
ServerGeoObjectType type = ServerGeoObjectType.get(universal);
typeCodeMap.put(type.getCode(), type);
}
}
return typeCodeMap;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class GeoObjectTypeMetadata method hasPrivateParents.
public boolean hasPrivateParents() {
List<ServerHierarchyType> hierarchyTypes = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
final Universal root = Universal.getRoot();
for (ServerHierarchyType ht : hierarchyTypes) {
Collection<Term> uniParents = GeoEntityUtil.getOrderedAncestors(root, this.getUniversal(), ht.getUniversalType());
if (uniParents.size() > 1) {
for (Term uniParent : uniParents) {
if (!this.getKey().equals(uniParent.getKey()) && GeoObjectTypeMetadata.getByKey(uniParent.getKey()).getIsPrivate()) {
return true;
}
}
}
}
return false;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class PatchExistsAndInvalid method addAttributes.
@Transaction
private void addAttributes() {
List<Universal> unis = getUniversals();
for (Universal uni : unis) {
MdBusinessDAO bizDAO = (MdBusinessDAO) BusinessFacade.getEntityDAO(uni.getMdBusiness());
MdAttributeConcreteDAO postgresStatusAttr = (MdAttributeConcreteDAO) bizDAO.definesAttribute(STATUS_ATTRIBUTE_NAME);
if (postgresStatusAttr != null) {
postgresStatusAttr.delete();
}
MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
MdAttributeEnumerationDAO statusMdAttr = (MdAttributeEnumerationDAO) mdVertex.definesAttribute(STATUS_ATTRIBUTE_NAME);
if (statusMdAttr != null) {
statusMdAttr.delete();
}
}
for (Universal uni : unis) {
ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
MdGraphClassDAOIF mdClass = type.getMdVertex();
MdAttributeDAOIF existing = mdClass.definesAttribute(DefaultAttribute.EXISTS.getName());
if (existing == null) {
logger.info("Adding new attributes to [" + mdClass.getKey() + "].");
MdAttributeBooleanDAO existsMdAttr = MdAttributeBooleanDAO.newInstance();
existsMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.EXISTS.getName());
existsMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultLocalizedName());
existsMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultDescription());
existsMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
existsMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
existsMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
existsMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
existsMdAttr.apply();
MdAttributeBooleanDAO invalidMdAttr = MdAttributeBooleanDAO.newInstance();
invalidMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.INVALID.getName());
invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultLocalizedName());
invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultDescription());
invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
invalidMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
invalidMdAttr.apply();
}
}
patchMasterlistVersions();
// TODO : We can't actually set this field to required unfortunately because of many different graph bugs.
// If we set it to required immediately when it's created, orientdb throws an error saying that objects
// don't have a required field. If we try to update the field to set it as required after the instance
// data has been patched, Runway tries to create the attribute twice because the MdAttribute in the cache
// still has the 'isNew' flag set to true. We can't do this in a separate transaction because the patching
// transaction is controlled at a higher level than we have access to here.
// enforceInvalidRequired();
}
Aggregations