use of org.openforis.collect.model.NodeChangeSet in project collect by openforis.
the class DataService method updateRecord.
private NodeChangeSet updateRecord(CollectRecord record, NodeUpdateRequestSet nodeUpdateRequestSet) throws RecordPersistenceException, RecordIndexException {
List<NodeUpdateRequest> opts = nodeUpdateRequestSet.getRequests();
NodeChangeMap result = new NodeChangeMap();
for (NodeUpdateRequest req : opts) {
NodeChangeSet partialChangeSet = updateRecord(record, req);
result.addMergeChanges(partialChangeSet);
}
return result;
}
use of org.openforis.collect.model.NodeChangeSet in project collect by openforis.
the class DataService method updateActiveRecord.
@Transactional
@Secured(ENTRY_LIMITED)
public NodeChangeSetProxy updateActiveRecord(NodeUpdateRequestSetProxy requestSet) throws RecordPersistenceException, RecordIndexException {
sessionManager.checkIsActiveRecordLocked();
CollectRecord activeRecord = getActiveRecord();
NodeUpdateRequestSet reqSet = requestSet.toNodeUpdateRequestSet(codeListManager, sessionManager, activeRecord);
NodeChangeSet changeSet = updateRecord(activeRecord, reqSet);
if (!changeSet.isEmpty() && isCurrentRecordIndexable()) {
recordIndexService.temporaryIndex(activeRecord);
}
String userName = sessionManager.getSessionState().getUser().getUsername();
List<RecordEvent> events = new EventProducer().produceFor(changeSet, userName);
sessionManager.onEvents(events);
NodeChangeSetProxy result = new NodeChangeSetProxy(activeRecord, changeSet, getProxyContext());
if (requestSet.isAutoSave()) {
try {
saveActiveRecord();
result.setRecordSaved(true);
} catch (Exception e) {
result.setRecordSaved(false);
}
}
return result;
}
use of org.openforis.collect.model.NodeChangeSet in project collect by openforis.
the class CSVDataImportProcess method setSRSIdField.
private void setSRSIdField(Attribute<?, ?> attr, String value, long row, String colName) {
boolean valid = true;
if (StringUtils.isNotBlank(value)) {
// check SRS id validity
Survey survey = attr.getSurvey();
SpatialReferenceSystem srs = survey.getSpatialReferenceSystem(value);
if (srs == null) {
ParsingError parsingError = new ParsingError(ErrorType.INVALID_VALUE, row, colName, SRS_NOT_FOUND_MESSAGE_KEY);
parsingError.setMessageArgs(new String[] { value });
status.addParsingError(parsingError);
valid = false;
}
}
if (valid) {
Field<String> field = ((CoordinateAttribute) attr).getSrsIdField();
NodeChangeSet changes = recordUpdater.updateField(field, value);
if (nodeChangeBatchProcessor != null) {
nodeChangeBatchProcessor.add(changes, adminUser.getUsername());
}
}
}
use of org.openforis.collect.model.NodeChangeSet in project collect by openforis.
the class AddNodeCommandHandler method execute.
@Override
public List<RecordEvent> execute(C command) {
CollectRecord record = findRecord(command);
Entity parentEntity = record.findNodeByPath(command.getParentEntityPath());
NodeDefinition nodeDef = parentEntity.getDefinition().getChildDefinition(command.getNodeDefId());
NodeChangeSet changeSet = recordUpdater.addNode(parentEntity, nodeDef);
recordManager.save(record);
List<RecordEvent> events = new EventProducer().produceFor(changeSet, command.getUsername());
return events;
}
use of org.openforis.collect.model.NodeChangeSet in project collect by openforis.
the class UpdateAttributeCommandHandler method execute.
@Override
public List<RecordEvent> execute(UpdateAttributeCommand command) {
CollectRecord record = findRecord(command);
Attribute<?, Value> attribute = findAttribute(command, record);
Value value = extractValue(command);
NodeChangeSet changeSet = recordUpdater.updateAttribute(attribute, value);
recordManager.save(record);
List<RecordEvent> events = new EventProducer().produceFor(changeSet, command.getUsername());
return events;
}
Aggregations