use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class GeoObjectEditorControllerNoOverTime method applyInTransaction.
@Transaction
private GeoObject applyInTransaction(String sessionId, String sPtn, String sGo, Boolean isNew, String masterListId) {
final Date startDate = new Date();
final Date endDate = ValueOverTime.INFINITY_END_DATE;
GeoObject go;
Map<String, String> roles = Session.getCurrentSession().getUserRoles();
if (roles.keySet().contains(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE)) {
Instant base = Instant.now();
int sequence = 0;
ChangeRequest request = new ChangeRequest();
request.addApprovalStatus(AllGovernanceStatus.PENDING);
request.apply();
if (!isNew) {
UpdateGeoObjectAction action = new UpdateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
} else {
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyChangeRequest(sessionId, request, ptn, isNew, base, sequence, startDate, endDate);
} else {
if (!isNew) {
go = RegistryService.getInstance().updateGeoObject(sessionId, sGo.toString(), startDate, endDate);
} else {
go = RegistryService.getInstance().createGeoObject(sessionId, sGo.toString(), startDate, endDate);
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyPtn(sessionId, ptn, startDate, endDate);
// Update the master list record
if (masterListId != null) {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF geoObject = service.getGeoObject(go);
if (!isNew) {
ListTypeVersion.get(masterListId).updateRecord(geoObject);
} else {
ListTypeVersion.get(masterListId).publishRecord(geoObject);
}
}
return go;
}
return null;
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method createDefaultAttributes.
@Transaction
public void createDefaultAttributes(Universal universal, MdGraphClassDAOIF mdClass) {
MdAttributeUUIDDAO uuidMdAttr = MdAttributeUUIDDAO.newInstance();
uuidMdAttr.setValue(MdAttributeConcreteInfo.NAME, RegistryConstants.UUID);
uuidMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, RegistryConstants.UUID_LABEL);
uuidMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, RegistryConstants.UUID_LABEL);
uuidMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
uuidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
uuidMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.UNIQUE_INDEX.getOid());
uuidMdAttr.apply();
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.TRUE);
invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
invalidMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
invalidMdAttr.apply();
// DefaultAttribute.DISPLAY_LABEL
MdAttributeLocalCharacterEmbeddedDAO labelMdAttr = MdAttributeLocalCharacterEmbeddedDAO.newInstance();
labelMdAttr.setValue(MdAttributeLocalCharacterEmbeddedInfo.NAME, DefaultAttribute.DISPLAY_LABEL.getName());
labelMdAttr.setStructValue(MdAttributeLocalCharacterEmbeddedInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.DISPLAY_LABEL.getDefaultLocalizedName());
labelMdAttr.setStructValue(MdAttributeLocalCharacterEmbeddedInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.DISPLAY_LABEL.getDefaultDescription());
labelMdAttr.setValue(MdAttributeLocalCharacterEmbeddedInfo.DEFINING_MD_CLASS, mdClass.getOid());
labelMdAttr.setValue(MdAttributeLocalCharacterEmbeddedInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
labelMdAttr.apply();
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ServerHierarchyTypeBuilder method createHierarchyType.
@Transaction
public ServerHierarchyType createHierarchyType(HierarchyType hierarchyType) {
if (hierarchyType.getOrganizationCode() == null || hierarchyType.getOrganizationCode().equals("")) {
// TODO : A better exception
throw new AttributeValueException("Organization code cannot be null.", hierarchyType.getOrganizationCode());
}
Organization organization = Organization.getByCode(hierarchyType.getOrganizationCode());
String addons = new String(RegistryConstants.UNIVERSAL_RELATIONSHIP_POST + "AllPathsTable");
if (hierarchyType.getCode().length() > (64 - addons.length())) {
// Initializing the Universal allpaths strategy creates this limitation.
CodeLengthException ex = new CodeLengthException();
ex.setLength(64 - addons.length());
throw ex;
}
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();
InitializationStrategyIF strategy = new InitializationStrategyIF() {
@Override
public void preApply(MdBusinessDAO mdBusiness) {
mdBusiness.setValue(MdBusinessInfo.GENERATE_SOURCE, MdAttributeBooleanInfo.FALSE);
}
@Override
public void postApply(MdBusinessDAO mdBusiness) {
RoleDAO adminRole = RoleDAO.findRole(DefaultConfiguration.ADMIN).getBusinessDAO();
adminRole.grantPermission(Operation.READ, mdBusiness.getOid());
adminRole.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE, mdBusiness.getOid());
adminRole.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
adminRole.grantPermission(Operation.CREATE, mdBusiness.getOid());
adminRole.grantPermission(Operation.DELETE, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ, mdBusiness.getOid());
maintainer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE, mdBusiness.getOid());
maintainer.grantPermission(Operation.WRITE_ALL, mdBusiness.getOid());
maintainer.grantPermission(Operation.CREATE, mdBusiness.getOid());
maintainer.grantPermission(Operation.DELETE, mdBusiness.getOid());
consumer.grantPermission(Operation.READ, mdBusiness.getOid());
consumer.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
contributor.grantPermission(Operation.READ, mdBusiness.getOid());
contributor.grantPermission(Operation.READ_ALL, mdBusiness.getOid());
}
};
try {
MdTermRelationship mdTermRelUniversal = this.newHierarchyToMdTermRelForUniversals(hierarchyType);
mdTermRelUniversal.apply();
this.grantWritePermissionsOnMdTermRel(mdTermRelUniversal);
this.grantWritePermissionsOnMdTermRel(maintainer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(consumer, mdTermRelUniversal);
this.grantReadPermissionsOnMdTermRel(contributor, mdTermRelUniversal);
Universal.getStrategy().initialize(mdTermRelUniversal.definesType(), strategy);
MdEdge mdEdge = this.createMdEdge(hierarchyType);
this.grantWritePermissionsOnMdTermRel(mdEdge);
this.grantWritePermissionsOnMdTermRel(maintainer, mdEdge);
this.grantReadPermissionsOnMdTermRel(consumer, mdEdge);
this.grantReadPermissionsOnMdTermRel(contributor, mdEdge);
HierarchicalRelationshipType hierarchicalRelationship = new HierarchicalRelationshipType();
hierarchicalRelationship.setCode(hierarchyType.getCode());
hierarchicalRelationship.setOrganization(organization);
populate(hierarchicalRelationship.getDisplayLabel(), hierarchyType.getLabel());
populate(hierarchicalRelationship.getDescription(), hierarchyType.getDescription());
hierarchicalRelationship.setMdTermRelationship(mdTermRelUniversal);
hierarchicalRelationship.setMdEdge(mdEdge);
hierarchicalRelationship.setAbstractDescription(hierarchyType.getAbstractDescription());
hierarchicalRelationship.setAcknowledgement(hierarchyType.getAcknowledgement());
hierarchicalRelationship.setDisclaimer(hierarchyType.getDisclaimer());
hierarchicalRelationship.setContact(hierarchyType.getContact());
hierarchicalRelationship.setPhoneNumber(hierarchyType.getPhoneNumber());
hierarchicalRelationship.setEmail(hierarchyType.getEmail());
hierarchicalRelationship.setProgress(hierarchyType.getProgress());
hierarchicalRelationship.setAccessConstraints(hierarchyType.getAccessConstraints());
hierarchicalRelationship.setUseConstraints(hierarchyType.getUseConstraints());
hierarchicalRelationship.apply();
return this.get(hierarchicalRelationship);
} catch (DuplicateDataException ex) {
DuplicateHierarchyTypeException ex2 = new DuplicateHierarchyTypeException();
ex2.setDuplicateValue(hierarchyType.getCode());
throw ex2;
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class TermConverter method createClassifierFromTerm.
@Transaction
public static Classifier createClassifierFromTerm(String parentTermCode, Term term) {
String parentClassifierKey = buildClassifierKeyFromTermCode(parentTermCode);
Classifier parent = Classifier.getByKey(parentClassifierKey);
enforceTermPermissions(parent, CGRPermissionAction.CREATE);
Classifier classifier = new Classifier();
classifier.setClassifierId(term.getCode());
classifier.setClassifierPackage(parent.getKey());
// This will set the value of the display label to the locale of the user
// performing the action.
LocalizedValueConverter.populate(classifier.getDisplayLabel(), term.getLabel());
classifier.apply();
classifier.addLink(parent, ClassifierIsARelationship.CLASS);
return classifier;
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class FhirResourceImporter method recordExportError.
@Transaction
private void recordExportError(Exception ex, ExportHistory history, Resource resource) {
if (ex instanceof ProgrammingErrorException) {
logger.error("Unknown error while processing the FHIR resource [" + resource.getId() + "]", ex);
}
if (this.history != null) {
ExportError exportError = new ExportError();
exportError.setCode(resource.getId());
if (ex != null) {
exportError.setErrorJson(JobHistory.exceptionToJson(ex).toString());
}
// exportError.setRowIndex(ee.rowIndex);
exportError.setHistory(history);
exportError.apply();
}
}
Aggregations