use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class BusinessType method getAttributeMap.
public Map<String, AttributeType> getAttributeMap() {
AttributeTypeConverter converter = new AttributeTypeConverter();
MdVertexDAOIF mdVertex = this.getMdVertexDAO();
return mdVertex.definesAttributes().stream().filter(attr -> {
return !attr.isSystem() && !attr.definesAttribute().equals(BusinessType.SEQ) && !attr.definesAttribute().equals(BusinessType.GEO_OBJECT);
}).map(attr -> converter.build(attr)).collect(Collectors.toMap(AttributeType::getName, attr -> attr));
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class BusinessType method apply.
@Transaction
public static BusinessType apply(JsonObject object) {
String code = object.get(BusinessType.CODE).getAsString();
String organizationCode = object.get(BusinessType.ORGANIZATION).getAsString();
Organization organization = Organization.getByCode(organizationCode);
ServiceFactory.getGeoObjectTypePermissionService().enforceCanCreate(organization.getCode(), false);
if (!MasterList.isValidName(code)) {
throw new InvalidMasterListCodeException("The geo object type code has an invalid character");
}
if (code.length() > 64) {
// Setting the typename on the MdBusiness creates this limitation.
CodeLengthException ex = new CodeLengthException();
ex.setLength(64);
throw ex;
}
// assignSRAPermissions(mdVertex, mdBusiness);
// assignAll_RA_Permissions(mdVertex, mdBusiness, organizationCode);
LocalizedValue localizedValue = LocalizedValue.fromJSON(object.get(DISPLAYLABEL).getAsJsonObject());
BusinessType businessType = (object.has(OID) && !object.get(OID).isJsonNull()) ? BusinessType.get(object.get(OID).getAsString()) : new BusinessType();
businessType.setCode(code);
businessType.setOrganization(organization);
LocalizedValueConverter.populate(businessType.getDisplayLabel(), localizedValue);
boolean isNew = businessType.isNew();
if (isNew) {
MdVertexDAO mdVertex = MdVertexDAO.newInstance();
mdVertex.setValue(MdGeoVertexInfo.PACKAGE, RegistryConstants.BUSINESS_PACKAGE);
mdVertex.setValue(MdGeoVertexInfo.NAME, code);
mdVertex.setValue(MdGeoVertexInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.FALSE);
mdVertex.setValue(MdGeoVertexInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
LocalizedValueConverter.populate(mdVertex, MdVertexInfo.DISPLAY_LABEL, localizedValue);
mdVertex.apply();
// TODO CREATE the edge between this class and GeoVertex??
MdVertexDAOIF mdGeoVertexDAO = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdAttributeGraphReferenceDAO mdGeoObject = MdAttributeGraphReferenceDAO.newInstance();
mdGeoObject.setValue(MdAttributeGraphReferenceInfo.REFERENCE_MD_VERTEX, mdGeoVertexDAO.getOid());
mdGeoObject.setValue(MdAttributeGraphReferenceInfo.DEFINING_MD_CLASS, mdVertex.getOid());
mdGeoObject.setValue(MdAttributeGraphReferenceInfo.NAME, GEO_OBJECT);
mdGeoObject.setStructValue(MdAttributeGraphReferenceInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Geo Object");
mdGeoObject.apply();
// DefaultAttribute.CODE
MdAttributeCharacterDAO vertexCodeMdAttr = MdAttributeCharacterDAO.newInstance();
vertexCodeMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.CODE.getName());
vertexCodeMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.CODE.getDefaultLocalizedName());
vertexCodeMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.CODE.getDefaultDescription());
vertexCodeMdAttr.setValue(MdAttributeCharacterInfo.SIZE, MdAttributeCharacterInfo.MAX_CHARACTER_SIZE);
vertexCodeMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdVertex.getOid());
vertexCodeMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
vertexCodeMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.UNIQUE_INDEX.getOid());
vertexCodeMdAttr.apply();
businessType.setMdVertexId(mdVertex.getOid());
// Assign permissions
Roles role = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
RoleDAO roleDAO = (RoleDAO) BusinessFacade.getEntityDAO(role);
roleDAO.grantPermission(Operation.CREATE, mdVertex.getOid());
roleDAO.grantPermission(Operation.DELETE, mdVertex.getOid());
roleDAO.grantPermission(Operation.WRITE, mdVertex.getOid());
roleDAO.grantPermission(Operation.WRITE_ALL, mdVertex.getOid());
}
businessType.apply();
return businessType;
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class MasterListVersion method publish.
private void publish(ServerGeoObjectIF go, Business business, Collection<AttributeType> attributes, Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap, Set<ServerHierarchyType> hierarchiesOfSubTypes, Collection<Locale> locales) {
VertexServerGeoObject vertexGo = (VertexServerGeoObject) go;
boolean hasData = false;
business.setValue(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME, go.getGeometry());
for (AttributeType attribute : attributes) {
String name = attribute.getName();
business.setValue(ORIGINAL_OID, go.getRunwayId());
if (this.isValid(attribute)) {
Object value = go.getValue(name, this.getForDate());
if (value != null) {
if (value instanceof LocalizedValue && ((LocalizedValue) value).isNull()) {
continue;
}
if (!name.equals(DefaultAttribute.CODE.getName()) && !name.equals(DefaultAttribute.INVALID.getName()) && attribute.isChangeOverTime() && (!name.equals(DefaultAttribute.EXISTS.getName()) || (value instanceof Boolean && ((Boolean) value)))) {
hasData = true;
}
if (attribute instanceof AttributeTermType) {
Classifier classifier = (Classifier) value;
Term term = ((AttributeTermType) attribute).getTermByCode(classifier.getClassifierId()).get();
LocalizedValue label = term.getLabel();
this.setValue(business, name, term.getCode());
this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
for (Locale locale : locales) {
this.setValue(business, name + locale.toString(), label.getValue(locale));
}
} else if (attribute instanceof AttributeClassificationType) {
String classificationType = ((AttributeClassificationType) attribute).getClassificationType();
MdClassificationDAOIF mdClassificationDAO = MdClassificationDAO.getMdClassificationDAO(classificationType);
MdVertexDAOIF mdVertexDAO = mdClassificationDAO.getReferenceMdVertexDAO();
VertexObject classification = VertexObject.get(mdVertexDAO, (String) value);
LocalizedValue label = LocalizedValueConverter.convert(classification.getEmbeddedComponent(AbstractClassification.DISPLAYLABEL));
this.setValue(business, name, classification.getObjectValue(AbstractClassification.CODE));
this.setValue(business, name + DEFAULT_LOCALE, label.getValue(LocalizedValue.DEFAULT_LOCALE));
for (Locale locale : locales) {
this.setValue(business, name + locale.toString(), label.getValue(locale));
}
} else if (attribute instanceof AttributeLocalType) {
LocalizedValue label = (LocalizedValue) value;
String defaultLocale = label.getValue(LocalizedValue.DEFAULT_LOCALE);
if (defaultLocale == null) {
defaultLocale = "";
}
this.setValue(business, name + DEFAULT_LOCALE, defaultLocale);
for (Locale locale : locales) {
String localeValue = label.getValue(locale);
if (localeValue == null) {
localeValue = "";
}
this.setValue(business, name + locale.toString(), localeValue);
}
} else {
this.setValue(business, name, value);
}
}
}
}
if (hasData) {
Set<Entry<ServerHierarchyType, List<ServerGeoObjectType>>> entries = ancestorMap.entrySet();
for (Entry<ServerHierarchyType, List<ServerGeoObjectType>> entry : entries) {
ServerHierarchyType hierarchy = entry.getKey();
Map<String, LocationInfo> map = vertexGo.getAncestorMap(hierarchy, entry.getValue());
Set<Entry<String, LocationInfo>> locations = map.entrySet();
for (Entry<String, LocationInfo> location : locations) {
String pCode = location.getKey();
LocationInfo vObject = location.getValue();
if (vObject != null) {
String attributeName = hierarchy.getCode().toLowerCase() + pCode.toLowerCase();
this.setValue(business, attributeName, vObject.getCode());
this.setValue(business, attributeName + DEFAULT_LOCALE, vObject.getLabel());
for (Locale locale : locales) {
this.setValue(business, attributeName + locale.toString(), vObject.getLabel(locale));
}
}
}
}
for (ServerHierarchyType hierarchy : hierarchiesOfSubTypes) {
ServerParentTreeNode node = go.getParentsForHierarchy(hierarchy, false, this.getForDate());
List<ServerParentTreeNode> parents = node.getParents();
if (parents.size() > 0) {
ServerParentTreeNode parent = parents.get(0);
String attributeName = hierarchy.getCode().toLowerCase();
ServerGeoObjectIF geoObject = parent.getGeoObject();
LocalizedValue label = geoObject.getDisplayLabel();
this.setValue(business, attributeName, geoObject.getCode());
this.setValue(business, attributeName + DEFAULT_LOCALE, label.getValue(DEFAULT_LOCALE));
for (Locale locale : locales) {
this.setValue(business, attributeName + locale.toString(), label.getValue(locale));
}
}
}
business.apply();
}
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class UndirectedGraphType method create.
@Transaction
public static UndirectedGraphType create(String code, LocalizedValue label, LocalizedValue description) {
RoleDAO maintainer = RoleDAO.findRole(RegistryConstants.REGISTRY_MAINTAINER_ROLE).getBusinessDAO();
RoleDAO consumer = RoleDAO.findRole(RegistryConstants.API_CONSUMER_ROLE).getBusinessDAO();
RoleDAO contributor = RoleDAO.findRole(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE).getBusinessDAO();
try {
MdVertexDAOIF mdBusGeoEntity = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdEdgeDAO mdEdgeDAO = MdEdgeDAO.newInstance();
mdEdgeDAO.setValue(MdEdgeInfo.PACKAGE, RegistryConstants.UNDIRECTED_GRAPH_PACKAGE);
mdEdgeDAO.setValue(MdEdgeInfo.NAME, code);
mdEdgeDAO.setValue(MdEdgeInfo.PARENT_MD_VERTEX, mdBusGeoEntity.getOid());
mdEdgeDAO.setValue(MdEdgeInfo.CHILD_MD_VERTEX, mdBusGeoEntity.getOid());
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DISPLAY_LABEL, label);
LocalizedValueConverter.populate(mdEdgeDAO, MdEdgeInfo.DESCRIPTION, description);
mdEdgeDAO.setValue(MdEdgeInfo.ENABLE_CHANGE_OVER_TIME, MdAttributeBooleanInfo.FALSE);
mdEdgeDAO.apply();
MdAttributeDateTimeDAO startDate = MdAttributeDateTimeDAO.newInstance();
startDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.START_DATE);
startDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "Start Date");
startDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
startDate.apply();
MdAttributeDateTimeDAO endDate = MdAttributeDateTimeDAO.newInstance();
endDate.setValue(MdAttributeDateTimeInfo.NAME, GeoVertex.END_DATE);
endDate.setStructValue(MdAttributeDateTimeInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setStructValue(MdAttributeDateTimeInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, "End Date");
endDate.setValue(MdAttributeDateTimeInfo.DEFINING_MD_CLASS, mdEdgeDAO.getOid());
endDate.apply();
ServerHierarchyTypeBuilder permissionBuilder = new ServerHierarchyTypeBuilder();
permissionBuilder.grantWritePermissionsOnMdTermRel(mdEdgeDAO);
permissionBuilder.grantWritePermissionsOnMdTermRel(maintainer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(consumer, mdEdgeDAO);
permissionBuilder.grantReadPermissionsOnMdTermRel(contributor, mdEdgeDAO);
UndirectedGraphType graphType = new UndirectedGraphType();
graphType.setCode(code);
graphType.setMdEdgeId(mdEdgeDAO.getOid());
LocalizedValueConverter.populate(graphType.getDisplayLabel(), label);
LocalizedValueConverter.populate(graphType.getDescription(), description);
graphType.apply();
return graphType;
} catch (DuplicateDataException ex) {
DuplicateHierarchyTypeException ex2 = new DuplicateHierarchyTypeException();
ex2.setDuplicateValue(code);
throw ex2;
}
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class FhirExternalSystem method isFhirOauth.
public static boolean isFhirOauth(OauthServer server) {
final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(FhirExternalSystem.CLASS);
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(OAUTHSERVER);
StringBuilder builder = new StringBuilder();
builder.append("SELECT COUNT(*) FROM " + mdVertex.getDBClassName());
builder.append(" WHERE " + mdAttribute.getColumnName() + " = :server");
final GraphQuery<Long> query = new GraphQuery<Long>(builder.toString());
query.setParameter("server", server.getOid());
return (query.getSingleResult() > 0);
}
Aggregations