use of fi.otavanopisto.muikku.plugins.material.model.QueryConnectFieldTerm in project muikku by otavanopisto.
the class QueryConnectFieldController method deleteQueryConnectField.
public void deleteQueryConnectField(QueryConnectField queryField, boolean removeAnswers) {
queryFieldDeleteEvent.fire(new QueryFieldDeleteEvent(queryField, removeAnswers));
for (QueryConnectFieldTerm term : listConnectFieldTermsByField(queryField)) {
queryConnectFieldTermDAO.delete(term);
}
for (QueryConnectFieldCounterpart counterpart : listQueryConnectFieldCounterpartByField(queryField)) {
queryConnectFieldCounterpartDAO.delete(counterpart);
}
queryConnectFieldDAO.delete(queryField);
}
use of fi.otavanopisto.muikku.plugins.material.model.QueryConnectFieldTerm in project muikku by otavanopisto.
the class WorkspaceConnectFieldIOHandler method store.
@Override
public void store(WorkspaceMaterialField field, WorkspaceMaterialReply reply, String value) throws WorkspaceFieldIOException {
Map<String, String> valueMap = null;
try {
valueMap = new ObjectMapper().readValue(value, new TypeReference<Map<String, String>>() {
});
} catch (IOException e) {
throw new WorkspaceFieldIOException("Could not unmarshal field response", e);
}
QueryConnectField queryConnectField = (QueryConnectField) field.getQueryField();
if (queryConnectField != null) {
List<QueryConnectFieldTerm> terms = queryConnectFieldController.listConnectFieldTermsByField(queryConnectField);
for (QueryConnectFieldTerm term : terms) {
String parameterValue = valueMap.get(term.getName());
QueryConnectFieldCounterpart counterpart = StringUtils.isNotEmpty(parameterValue) ? queryConnectFieldController.findQueryConnectFieldCounterpartByFieldAndName(queryConnectField, parameterValue) : null;
WorkspaceMaterialConnectFieldAnswer connectFieldAnswer = workspaceMaterialFieldAnswerController.findWorkspaceMaterialConnectFieldAnswerByFieldAndReplyAndTerm(field, reply, term);
if (connectFieldAnswer != null) {
workspaceMaterialFieldAnswerController.updateWorkspaceMaterialConnectFieldAnswerCounterpart(connectFieldAnswer, counterpart);
} else {
if (counterpart != null) {
workspaceMaterialFieldAnswerController.createWorkspaceMaterialConnectFieldAnswer(field, reply, term, counterpart);
}
}
}
} else {
throw new WorkspaceFieldIOException("Workspace material connect field #" + field.getId() + " points to non-existing field ");
}
}
Aggregations