Commit 72825006 authored by Klas, Claus-Peter's avatar Klas, Claus-Peter
Browse files

cleanup cache, when storing/creating a new study group

parent e14fa130
Pipeline #15170 passed with stage
in 1 minute and 47 seconds
......@@ -111,7 +111,7 @@ public class EntityCreationService {
group.addStudyReference(studyUnit.getId());
group.save();
group.setDdiStore( restClient.saveElement(group.getDdiStore(), user, comment));
group.setDdiStore(restClient.saveElement(group.getDdiStore(), user, comment));
} catch (Exception ex) {
ex.printStackTrace();
}
......@@ -166,7 +166,7 @@ public class EntityCreationService {
studyUnit.addInstrumentReference(instrument.getId());
studyUnit.save();
studyUnit.setDdiStore( restClient.saveElement(studyUnit.getDdiStore(), user, comment));
studyUnit.setDdiStore(restClient.saveElement(studyUnit.getDdiStore(), user, comment));
// adding a simple answer category scheme
CategoryScheme categoryScheme = new CategoryScheme();
......@@ -184,7 +184,7 @@ public class EntityCreationService {
categoryScheme.addCategory(catNo);
categoryScheme.setContainerId(instrument.getId());
categoryScheme.save();
categoryScheme.setDdiStore( restClient.saveElement(categoryScheme.getDdiStore(), user, comment));
categoryScheme.setDdiStore(restClient.saveElement(categoryScheme.getDdiStore(), user, comment));
CodeList codeList = new CodeList();
codeList.init("CLS", instrument.getId(), instrument.getDialect());
......@@ -202,17 +202,18 @@ public class EntityCreationService {
codeList.addCode(noCode);
codeList.setContainerId(instrument.getId());
codeList.save();
codeList.setDdiStore( restClient.saveElement(codeList.getDdiStore(), user, comment));
codeList.setDdiStore(restClient.saveElement(codeList.getDdiStore(), user, comment));
// adding a first question to it QuestionConstruct construct =
QuestionConstruct construct = addNewQuestion(masterSequence, instrument, comment, true);
construct.setDdiStore( restClient.saveElement(construct.getDdiStore(), user, comment));
construct.getQuestion().setDdiStore( restClient.saveElement(construct.getQuestion().getDdiStore(), user, comment));
construct.setDdiStore(restClient.saveElement(construct.getDdiStore(), user, comment));
construct.getQuestion()
.setDdiStore(restClient.saveElement(construct.getQuestion().getDdiStore(), user, comment));
masterSequence.save();
masterSequence.setDdiStore( restClient.saveElement(masterSequence.getDdiStore(), user, comment));
masterSequence.setDdiStore(restClient.saveElement(masterSequence.getDdiStore(), user, comment));
instrument.save();
instrument.setDdiStore( restClient.saveElement(instrument.getDdiStore(), user, comment));
instrument.setDdiStore(restClient.saveElement(instrument.getDdiStore(), user, comment));
} catch (Exception e) {
e.printStackTrace();
}
......@@ -264,7 +265,7 @@ public class EntityCreationService {
item.save();
String user = getUser();
item.setDdiStore( restClient.saveElement(item.getDdiStore(), user, "[create] " + comment));
item.setDdiStore(restClient.saveElement(item.getDdiStore(), user, "[create] " + comment));
return item;
}
......@@ -285,8 +286,8 @@ public class EntityCreationService {
qc.setQuestion(item);
qc.save();
if (instantPersist) {
qc.setDdiStore( restClient.saveElement(qc.getDdiStore(), user, comment));
qc.getQuestion().setDdiStore( restClient.saveElement(qc.getQuestion().getDdiStore(), user, comment));
qc.setDdiStore(restClient.saveElement(qc.getDdiStore(), user, comment));
qc.getQuestion().setDdiStore(restClient.saveElement(qc.getQuestion().getDdiStore(), user, comment));
insertConstructReference(qc.getId(), DDIElement.QUESTIONCONSTRUCT, currentSequence, comment);
}
return qc;
......@@ -381,11 +382,11 @@ public class EntityCreationService {
qc.setQuestion(item);
qc.save();
if (instantPersist) {
qc.setDdiStore( restClient.saveElement(qc.getDdiStore(), user, comment));
item.setDdiStore( restClient.saveElement(item.getDdiStore(), user, comment));
item.getCodeList().getCategoryScheme().setDdiStore( restClient
.saveElement(item.getCodeList().getCategoryScheme().getDdiStore(), user, comment));
item.getCodeList().setDdiStore( restClient.saveElement(item.getCodeList().getDdiStore(), user, comment));
qc.setDdiStore(restClient.saveElement(qc.getDdiStore(), user, comment));
item.setDdiStore(restClient.saveElement(item.getDdiStore(), user, comment));
item.getCodeList().getCategoryScheme().setDdiStore(
restClient.saveElement(item.getCodeList().getCategoryScheme().getDdiStore(), user, comment));
item.getCodeList().setDdiStore(restClient.saveElement(item.getCodeList().getDdiStore(), user, comment));
insertConstructReference(qc.getId(), DDIElement.QUESTIONCONSTRUCT, currentSequence, comment);
}
return qc;
......@@ -408,7 +409,7 @@ public class EntityCreationService {
item.setDescription(values.get("description").toString());
item.setDisplayText(values.get("displayText").toString());
item.save();
item.setDdiStore( restClient.saveElement(item.getDdiStore(), user, comment));
item.setDdiStore(restClient.saveElement(item.getDdiStore(), user, comment));
insertConstructReference(item.getId(), "StatementItem", currentSequence, predecessor, comment);
return item;
}
......@@ -807,7 +808,8 @@ public class EntityCreationService {
cs = new CategoryScheme(restClient.getElement(codeList.getContainerId(), DDIElement.CATEGORYSCHEME,
codeList.getCategorySchemeReference()));
}
restClient.deleteElement(cs.getDdiStore().getPrimaryKey(), getUser(), comment, cs.getDdiStore().getElementId());
restClient.deleteElement(cs.getDdiStore().getPrimaryKey(), getUser(), comment,
cs.getDdiStore().getElementId());
restClient.deleteElement(codeList.getDdiStore().getPrimaryKey(), getUser(), comment,
codeList.getDdiStore().getElementId());
result = 1;
......@@ -849,8 +851,8 @@ public class EntityCreationService {
progressListener.accept(new Float(95));
containerStudyGroup.addStudyReference(clone.getId());
containerStudyGroup.save();
containerStudyGroup.setDdiStore( restClient.saveElement(containerStudyGroup.getDdiStore(), user,
"[clone] " + comment));
containerStudyGroup
.setDdiStore(restClient.saveElement(containerStudyGroup.getDdiStore(), user, "[clone] " + comment));
if (succeededListener != null)
succeededListener.run();
} catch (IllegalArgumentException | SecurityException e) {
......@@ -894,14 +896,14 @@ public class EntityCreationService {
toClone.getId(), clone.getId(), user, comment);
clone.setSequenceReference(cloneSeq.getId());
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
if (progressListener != null)
progressListener.accept(new Float(95));
containerStudyUnit.addInstrumentReference(clone.getId());
containerStudyUnit.save();
containerStudyUnit.setDdiStore( getDdiElementRestCacheClient().saveElement(containerStudyUnit, user,
comment).getDdiStore());
containerStudyUnit.setDdiStore(
getDdiElementRestCacheClient().saveElement(containerStudyUnit, user, comment).getDdiStore());
if (succeededListener != null)
succeededListener.run();
List<DDIElement> vars = getDdiElementRestCacheClient().getElementList(toClone.getId(), DDIElement.VARIABLE);
......@@ -913,7 +915,7 @@ public class EntityCreationService {
var.setQuestionReference(questions.get(toCloneVar.getQuestionReference()));
var.setCodeListReference(codeLists.get(var.getCodeListReference()).getId());
// TODO add based on here
var.setDdiStore( getDdiElementRestCacheClient().saveElement(var, user, comment).getDdiStore());
var.setDdiStore(getDdiElementRestCacheClient().saveElement(var, user, comment).getDdiStore());
}
}
if (succeededListener != null)
......@@ -1002,7 +1004,7 @@ public class EntityCreationService {
}
}
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
} catch (IllegalArgumentException | SecurityException e) {
logger.error(e.getMessage());
logger.error(e.getStackTrace().toString());
......@@ -1078,7 +1080,7 @@ public class EntityCreationService {
}
clone.setQuestionReference(questions.get(constr.getQuestionReference()));
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
logger.error(e.getMessage());
......@@ -1092,7 +1094,7 @@ public class EntityCreationService {
InvocationTargetException, NoSuchMethodException, SecurityException {
InterviewerInstruction clone = (InterviewerInstruction) toClone.clone("IIS", newContainerId,
toClone.getDialect());
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
......@@ -1100,13 +1102,13 @@ public class EntityCreationService {
throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException,
NoSuchMethodException, SecurityException {
Universe clone = (Universe) toClone.clone("US", newContainerId, toClone.getDialect());
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
private Statement cloneStatement(Statement toClone, String newContainerId, String user, String comment) {
Statement clone = (Statement) toClone.clone("CCS", newContainerId, toClone.getDialect());
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
......@@ -1146,7 +1148,7 @@ public class EntityCreationService {
clone.setBasedOnReference(toClone.getId());
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
......@@ -1189,7 +1191,7 @@ public class EntityCreationService {
clone.setBasedOnReference(toClone.getId());
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
......@@ -1214,10 +1216,10 @@ public class EntityCreationService {
}
cloneCategoryScheme.save();
cloneCategoryScheme.setDdiStore( getDdiElementRestCacheClient().saveElement(cloneCategoryScheme, user,
comment).getDdiStore());
cloneCategoryScheme.setDdiStore(
getDdiElementRestCacheClient().saveElement(cloneCategoryScheme, user, comment).getDdiStore());
clone.save();
clone.setDdiStore( getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
clone.setDdiStore(getDdiElementRestCacheClient().saveElement(clone, user, comment).getDdiStore());
return clone;
}
......@@ -1248,7 +1250,7 @@ public class EntityCreationService {
currentSequence.addReference(ccr);
}
currentSequence.save();
currentSequence.setDdiStore( restClient.saveElement(currentSequence.getDdiStore(), getUser(), comment));
currentSequence.setDdiStore(restClient.saveElement(currentSequence.getDdiStore(), getUser(), comment));
}
public void setRestClient(CachingDDIFlatDBRestClient ddiFlatDBRestClient) {
......@@ -1304,6 +1306,9 @@ public class EntityCreationService {
document.setContent(studyGroup.getRawContent());
restClient.importDocument(document, getUser(), "[create] new study group" + studyGroup.getLabel());
restClient.resetCache();
getDdiElementRestCacheClient().resetCache();
DDIStore studyGroupStore = restClient.getElement(studyGroup.getId(), DDIElement.STUDYGROUP, studyGroup.getId());
studyGroup = new StudyGroup(studyGroupStore);
......@@ -1328,26 +1333,26 @@ public class EntityCreationService {
}
public StudyGroup getStudyGroupByRef(String ref) {
logger.debug("Load StudyGroup: " + ref);
logger.debug("Load StudyGroup: {}", ref);
DDIElement ddiElement = getDdiElementRestCacheClient().getElement(ref, DDIElement.STUDYGROUP, ref);
return (StudyGroup) ddiElement;
}
public StudyUnit getStudyUnitByRef(String ref) {
logger.debug("Load study: " + ref);
logger.debug("Load study: {}", ref);
DDIElement ddiElement = getDdiElementRestCacheClient().getElement(ref, DDIElement.STUDYUNIT, ref);
return (StudyUnit) ddiElement;
}
public Instrument getInstrumentByRef(String ref) {
logger.debug("Load instrument: " + ref);
logger.debug("Load instrument: {}", ref);
DDIElement instrumentStore = getDdiElementRestCacheClient().getElement(ref, DDIElement.INSTRUMENT, ref);
return (Instrument) instrumentStore;
}
public void fetchAllStudiesByStudyReferenceAsDDIStudyUnit(List<StudyUnit> studies, String ref) {
DDIElement ddiElement = getDdiElementRestCacheClient().getElement(ref, DDIElement.STUDYUNIT, ref);
logger.debug("Load study: " + ref);
logger.debug("Load study: {}", ref);
if (ddiElement != null) {
studies.add((StudyUnit) ddiElement);
}
......@@ -1562,7 +1567,7 @@ public class EntityCreationService {
}
public List<Variable> getAllVariablesbyQuestionReference(String questionReference) {
List<Variable> variableList = new ArrayList<Variable>();
List<Variable> variableList = new ArrayList<>();
List<DDIElement> elementList = getDdiElementRestCacheClient().getElementListByContent(DDIElement.VARIABLE,
questionReference);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment