use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class SearchService method remove.
// @Transaction
public void remove(String code) {
// String suffix = this.getSuffix();
//
// MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." +
// VERTEX_PREFIX + suffix);
// MdAttributeDAOIF mdCode = mdVertex.definesAttribute(CODE);
//
// StringBuilder statement = new StringBuilder();
// statement.append("DELETE VERTEX " + mdVertex.getDBClassName());
// statement.append(" WHERE " + mdCode.getColumnName() + " = :code");
//
// Map<String, Object> parameters = new HashMap<String, Object>();
// parameters.put("code", code);
//
// GraphDBService service = GraphDBService.getInstance();
// GraphRequest request = service.getGraphDBRequest();
//
// service.command(request, statement.toString(), parameters);
String suffix = this.getSuffix();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdAttributeDAOIF mdCode = mdVertex.definesAttribute(CODE);
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
statement.append(" WHERE :code = " + mdCode.getColumnName());
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
query.setParameter("code", code);
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
result.delete();
}
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class SearchService method insert.
// @Transaction
public void insert(VertexServerGeoObject object) {
this.remove(object.getCode());
String suffix = this.getSuffix();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(PACKAGE + "." + VERTEX_PREFIX + suffix);
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(PACKAGE + "." + EDGE_PREFIX + suffix);
ValueOverTimeCollection vots = object.getValuesOverTime(DefaultAttribute.DISPLAY_LABEL.getName());
for (ValueOverTime vot : vots) {
VertexObjectDAOIF value = (VertexObjectDAOIF) vot.getValue();
Set<String> attributeNames = LocalizationService.getLocaleNames();
for (String attributeName : attributeNames) {
String label = value.getObjectValue(attributeName);
if (label != null && label.length() > 0) {
VertexObject vertex = new VertexObject(mdVertex.definesType());
vertex.setValue(START_DATE, vot.getStartDate());
vertex.setValue(END_DATE, vot.getEndDate());
vertex.setValue(CODE, object.getCode());
vertex.setValue(LABEL, label);
vertex.setValue(VERTEX_TYPE, object.getType().getCode());
vertex.apply();
vertex.addChild(object.getVertex(), mdEdge).apply();
}
}
}
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class BusinessType method getAttribute.
public AttributeType getAttribute(String name) {
AttributeTypeConverter converter = new AttributeTypeConverter();
MdVertexDAOIF mdVertex = this.getMdVertexDAO();
MdAttributeConcreteDAOIF mdAttribute = (MdAttributeConcreteDAOIF) mdVertex.definesAttribute(name);
return converter.build(mdAttribute);
}
use of com.runwaysdk.dataaccess.MdVertexDAOIF in project geoprism-registry by terraframe.
the class DirectedAcyclicGraphType method create.
@Transaction
public static DirectedAcyclicGraphType 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.DAG_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);
DirectedAcyclicGraphType graphType = new DirectedAcyclicGraphType();
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 ExternalSystem method getExternalSystemsForOrg.
public static List<ExternalSystem> getExternalSystemsForOrg(Integer pageNumber, Integer pageSize) {
List<Organization> organizations = Organization.getUserAdminOrganizations();
if (organizations.size() > 0) {
final MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(ExternalSystem.CLASS);
MdAttributeDAOIF oAttribute = mdVertex.definesAttribute(ExternalSystem.ORGANIZATION);
StringBuilder builder = new StringBuilder();
builder.append("SELECT FROM " + mdVertex.getDBClassName());
for (int i = 0; i < organizations.size(); i++) {
if (i == 0) {
builder.append(" WHERE " + oAttribute.getColumnName() + " = :org" + i);
} else {
builder.append(" OR " + oAttribute.getColumnName() + " = :org" + i);
}
}
builder.append(" ORDER BY id");
builder.append(" SKIP " + ((pageNumber - 1) * pageSize) + " LIMIT " + pageSize);
final GraphQuery<ExternalSystem> query = new GraphQuery<ExternalSystem>(builder.toString());
for (int i = 0; i < organizations.size(); i++) {
Organization organization = organizations.get(i);
query.setParameter("org" + i, organization.getOid());
}
return query.getResults();
}
return new LinkedList<ExternalSystem>();
}
Aggregations