Commit 904fefd2 authored by Nugraha, Sigit's avatar Nugraha, Sigit
Browse files

Merge branch '407-refactor-ddielement-usage'

parents f1bbed46 932d4fbb
Pipeline #15091 passed with stage
in 2 minutes and 19 seconds
......@@ -149,7 +149,7 @@
<dependency>
<groupId>org.gesis.stardat</groupId>
<artifactId>stardat-ddi-entities</artifactId>
<version>0.4.0-SNAPSHOT</version>
<version>0.4.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.docx4j</groupId>
......
......@@ -25,7 +25,7 @@ public class EntityRevisionResolver
switch (element.getType()) {
case DDIElement.QUESTIONCONSTRUCT:
QuestionConstruct currentConstruct = (QuestionConstruct) element;
Page<RevisionInformation> page = restClient.getElementRevisionsOfLastDays( element.ddiStore.getPrimaryKey(),
Page<RevisionInformation> page = restClient.getElementRevisionsOfLastDays( element.getDdiStore().getPrimaryKey(),
100, 0, 50 );
List<RevisionInformation> revisions = page.getItems();
QuestionConstruct lastConstruct = null;
......@@ -64,7 +64,7 @@ public class EntityRevisionResolver
if ( currentConstruct.getQuestionType().contains( "Grid" ) )
{
page = restClient.getElementRevisionsOfLastDays(
currentConstruct.getQuestion().ddiStore.getPrimaryKey(),
currentConstruct.getQuestion().getDdiStore().getPrimaryKey(),
100, 0, 50 );
revisions = page.getItems();
MultipleQuestionItem lastQuestion = null;
......@@ -108,7 +108,7 @@ public class EntityRevisionResolver
else
{
page = restClient.getElementRevisionsOfLastDays(
currentConstruct.getQuestion().ddiStore.getPrimaryKey(),
currentConstruct.getQuestion().getDdiStore().getPrimaryKey(),
100, 0, 50 );
revisions = page.getItems();
QuestionItem lastQuestion = null;
......@@ -152,7 +152,7 @@ public class EntityRevisionResolver
if ( currentConstruct.getUniverse() != null )
{
page = restClient.getElementRevisionsOfLastDays(
currentConstruct.getUniverse().ddiStore.getPrimaryKey(),
currentConstruct.getUniverse().getDdiStore().getPrimaryKey(),
100, 0, 50 );
revisions = page.getItems();
Universe lastUniverse = null;
......
......@@ -93,10 +93,6 @@ public class CachingSerializationDDIFlatDBClient
case DDIElement.VARIABLESTATISTICS:
ddiElement = new VariableStatistics( ddiStore );
break;
case DDIElement.STUDYLIST:
ddiElement = new StudyList( ddiStore );
break;
case DDIElement.STUDYUNIT:
ddiElement = new StudyUnit( ddiStore );
break;
......@@ -219,7 +215,7 @@ public class CachingSerializationDDIFlatDBClient
{
DDIStore ddiStore = getRestClient().saveElement( ddiElement.getDdiStore(), userName, comment );
ddiElement.ddiStore = ddiStore;
ddiElement.setDdiStore( ddiStore);
return ddiElement;
}
......
......@@ -54,7 +54,7 @@ public class ElementManager
public DDIElement saveElement( DDIElement ddiElement, String userName, String comment )
{
ddiElement.save();
DDIStore ddiStore = getDdiRestClient().saveElement( ddiElement.ddiStore, userName, comment );
DDIStore ddiStore = getDdiRestClient().saveElement( ddiElement.getDdiStore(), userName, comment );
ddiElement.load( ddiStore );
return ddiElement;
}
......
......@@ -43,8 +43,8 @@ public class StudyGroupService
public void save( StudyGroup studyGroup )
{
studyGroup.save();
studyGroup.ddiStore = getRestClient().saveElement( studyGroup.getDdiStore(),
DDIEditorSecurityUtils.getLoggedUserName(), "save studygroup " + studyGroup.getLabel() );
studyGroup.setDdiStore( getRestClient().saveElement( studyGroup.getDdiStore(),
DDIEditorSecurityUtils.getLoggedUserName(), "save studygroup " + studyGroup.getLabel() ));
}
public List<StudyGroup> findAll( String keyword )
......
......@@ -114,7 +114,7 @@ public class VariableService
+ qgr.getSequence() + "_" + countVariables++ );
var.setLabel( preText + qgr.getSequence() );
var.save();
// restClient.saveElement( var.ddiStore, getUser(), "creating new
// restClient.saveElement( var.getDdiStore(), getUser(), "creating new
// variable"
// );
}
......@@ -136,7 +136,7 @@ public class VariableService
var.setQuestionReference( qc.getQuestion().getId() );
var.setCodeListReference( mqi.getAnswerCodeListReference() );
var.save();
// restClient.saveElement( var.ddiStore, getUser(), "creating new
// restClient.saveElement( var.getDdiStore(), getUser(), "creating new
// variable"
// );
}
......@@ -157,7 +157,7 @@ public class VariableService
"Would replace label: " + var.getLabel() + " with " + preText + qgr.getSequence() );
var.setLabel( preText + qgr.getSequence() );
var.save();
// restClient.saveElement( var.ddiStore, getUser(), "creating new variable"
// restClient.saveElement( var.getDdiStore(), getUser(), "creating new variable"
// );
}
......@@ -174,7 +174,7 @@ public class VariableService
var.setQuestionReference( qi.getId() );
var.setCodeListReference( qi.getCodeListReference() );
var.save();
// restClient.saveElement( var.ddiStore, getUser(), "creating new variable"
// restClient.saveElement( var.getDdiStore(), getUser(), "creating new variable"
// );
}
......@@ -194,11 +194,11 @@ public class VariableService
"newStudy.label.fieldValue" )
+ new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format( new Date() ) );
studyUnit.save();
studyUnit.ddiStore = restClient.saveElement( studyUnit.ddiStore, getUser(), "GIT comment" );
studyUnit.setDdiStore( restClient.saveElement( studyUnit.getDdiStore(), getUser(), "GIT comment" ));
Document document = new Document();
document.setIdentifier( studyUnit.getId() );
document.setSplitConfigurationName( studyUnit.ddiStore.getDdiDialect() );
document.setFileName( studyUnit.getId() + "_" + studyUnit.ddiStore.getDdiDialect() + ".xml" );
document.setSplitConfigurationName( studyUnit.getDdiStore().getDdiDialect() );
document.setFileName( studyUnit.getId() + "_" + studyUnit.getDdiStore().getDdiDialect() + ".xml" );
document.setContent( null );
restClient.importDocument( document, getUser(), "GIT comment" );
......@@ -214,7 +214,7 @@ public class VariableService
cat1.setText( "nein" );
cs.addCategory( cat2 );
cs.save();
restClient.saveElement( cs.ddiStore, getUser(), "GIT comment" );
restClient.saveElement( cs.getDdiStore(), getUser(), "GIT comment" );
// Answer codes
CodeList cl = new CodeList();
......@@ -231,7 +231,7 @@ public class VariableService
code2.setCategoryReference( cat2.getId() );
cl.addCode( code2 );
cl.save();
restClient.saveElement( cl.ddiStore, getUser(), "GIT comment" );
restClient.saveElement( cl.getDdiStore(), getUser(), "GIT comment" );
// Variable
Variable var = new Variable();
......@@ -240,7 +240,7 @@ public class VariableService
var.setName( "V1" );
var.setCodeListReference( cl.getId() );
var.save();
restClient.saveElement( var.ddiStore, getUser(), "GIT comment" );
restClient.saveElement( var.getDdiStore(), getUser(), "GIT comment" );
// all variable statistics
VariableStatistics vs = new VariableStatistics();
......@@ -266,7 +266,7 @@ public class VariableService
vs.addCategoryStatistic( css2 );
vs.save();
restClient.saveElement( vs.ddiStore, getUser(), "GIT comment" );
restClient.saveElement( vs.getDdiStore(), getUser(), "GIT comment" );
return true;
}
......
......@@ -1786,10 +1786,10 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
.map( ms -> ms.getControlConstructReference() ).collect( Collectors.toList() ) ) );
// save and save to flatDB
masterSequence.save();
masterSequence.ddiStore = getEntityService().saveElement( masterSequence,
masterSequence.setDdiStore( getEntityService().saveElement( masterSequence,
DDIEditorSecurityUtils.getLoggedUserName(), "reorder " +
DDIElement.SEQUENCE + " Question reorder: " + selectedQuestions.stream()
.map( q -> q.getName() ).collect( Collectors.joining( ", " ) ) );
.map( q -> q.getName() ).collect( Collectors.joining( ", " ) ) ));
questionGrid.deselectAll();
fillTree();
......
......@@ -299,7 +299,7 @@ public class QuestionnaireOverView extends MVerticalLayout implements MView, Tra
}
else
{
System.out.println( ms.getContent() );
System.out.println( ms.getRawContent());
}
}
else
......
......@@ -209,10 +209,10 @@ public class AnswerCategoriesForm extends VerticalLayout implements ReferencePro
CodeList codeList = asw.getCurrentCodeList();
CategoryScheme categoryScheme = codeList.getCategoryScheme();
categoryScheme.save();
categoryScheme.ddiStore = restClient.saveElement( categoryScheme.ddiStore, getUi().getCurrentUserId(),
comment );
categoryScheme.setDdiStore( restClient.saveElement( categoryScheme.getDdiStore(), getUi().getCurrentUserId(),
comment ));
codeList.save();
codeList.ddiStore = restClient.saveElement( codeList.ddiStore, getUi().getCurrentUserId(), comment );
codeList.setDdiStore( restClient.saveElement( codeList.getDdiStore(), getUi().getCurrentUserId(), comment ));
if ( isNew )
{
currentCodeLists.add( codeList );
......
......@@ -90,17 +90,17 @@ public class CodeCategoryGrid extends MGrid<QuestionCodeCategory> implements Tra
// save categoryScheme
categoryScheme.save();
categoryScheme.ddiStore = questionWindow.getEntityService().saveElement( categoryScheme,
categoryScheme.setDdiStore( questionWindow.getEntityService().saveElement( categoryScheme,
DDIEditorSecurityUtils.getLoggedUserName(), "reorder " +
DDIElement.CATEGORYSCHEME.toString() + " Code-Category reorder: " + draggedRow.getCode().getValue() + " - "
+ draggedRow.getCategory().getText() );
+ draggedRow.getCategory().getText() ));
// save codelist
clist.save();
clist.ddiStore = questionWindow.getEntityService().saveElement( clist,
clist.setDdiStore( questionWindow.getEntityService().saveElement( clist,
DDIEditorSecurityUtils.getLoggedUserName(), "reorder " +
DDIElement.CODELIST.toString() + " Code-Category reorder: " + draggedRow.getCode().getValue() + " - "
+ draggedRow.getCategory().getText() );
+ draggedRow.getCategory().getText() ));
}
@Override
......
......@@ -76,8 +76,8 @@ public class InstructionWindow extends BaseStoreCancelWindow
String comment = "commitid:" + UUID.randomUUID().toString() + "# " + "[change] " + commentField.getValue();
instruction.save();
instruction.ddiStore = this.entityService.saveElement( instruction, getDDIEditor().getCurrentUserId(),
comment );
instruction.setDdiStore( this.entityService.saveElement( instruction, getDDIEditor().getCurrentUserId(),
comment ));
this.entityService.clearElementCacheForLists( instruction.getContainerId(), DDIElement.INTERVIEWERINSTRUCTION );
HashMap<String, Object> args = new HashMap<>();
......
......@@ -212,9 +212,9 @@ public class InterviewerInstructionForm extends MVerticalLayout
DDIElement.INTERVIEWERINSTRUCTION );
if ( goal.endsWith(DELETE_WINDOW) )
{
this.entityService.deleteElement( instruction.ddiStore.getPrimaryKey(),
this.entityService.deleteElement( instruction.getDdiStore().getPrimaryKey(),
getUi().getCurrentUserId(),
cw.getComment(), instruction.ddiStore.getElementId() );
cw.getComment(), instruction.getDdiStore().getElementId() );
updateInstructionGrid( this.instructionType );
}
else
......
......@@ -309,10 +309,10 @@ public class QuestionAnswerPanel extends CustomComponent
String comment = COMMITID + UUID.randomUUID().toString() + "# " + "[changed]";
CategoryScheme categoryScheme = codeList.getCategoryScheme();
categoryScheme.save();
categoryScheme.ddiStore = entityService.saveElement( categoryScheme, getUi().getCurrentUserId(),
comment );
categoryScheme.setDdiStore( entityService.saveElement( categoryScheme, getUi().getCurrentUserId(),
comment ));
codeList.save();
codeList.ddiStore = entityService.saveElement( codeList, getUi().getCurrentUserId(), comment );
codeList.setDdiStore( entityService.saveElement( codeList, getUi().getCurrentUserId(), comment ));
entityService.clearElementCacheForLists( codeList.getContainerId(), DDIElement.CODELIST );
if ( isNew )
{
......
......@@ -87,17 +87,17 @@ public class QuestionCodeCategoryWindow extends BaseStoreCancelWindow
// simply save either new or edit
// save categoryScheme
categoryScheme.save();
categoryScheme.ddiStore = questionWindow.getEntityService().saveElement( categoryScheme,
categoryScheme.setDdiStore( questionWindow.getEntityService().saveElement( categoryScheme,
DDIEditorSecurityUtils.getLoggedUserName(), "save " +
DDIElement.CATEGORYSCHEME.toString() + " Code-Category: " + currentCode.getValue() + " - "
+ currentCategory.getText() );
+ currentCategory.getText() ));
// save codelist
clist.save();
clist.ddiStore = questionWindow.getEntityService().saveElement( clist,
clist.setDdiStore( questionWindow.getEntityService().saveElement( clist,
DDIEditorSecurityUtils.getLoggedUserName(), "save " +
DDIElement.CODELIST.toString() + " Code-Category: " + currentCode.getValue() + " - "
+ currentCategory.getText() );
+ currentCategory.getText() ));
questionWindow.updateQuestionCodeCategoryGrid();
return true;
......
......@@ -404,8 +404,8 @@ public class QuestionTranslateWindow extends BaseStoreCancelWindow implements Tr
entityService.insertConstructReference( construct.getId(), construct.getType(), masterSequence,
constructPrevSibling != null ? constructPrevSibling.getId() : null, comment );
construct.save();
construct.ddiStore = getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(),
comment );
construct.setDdiStore( getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(),
comment ));
}
......@@ -443,15 +443,15 @@ public class QuestionTranslateWindow extends BaseStoreCancelWindow implements Tr
construct.setInterviewerInstruction( null );
}
construct.save();
construct.ddiStore = getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(), comment );
construct.setDdiStore( getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(), comment ));
if ( construct.getUniverse() == null )
{
getEntityService().addNewFilter( construct );
}
construct.getUniverse().setDescription( filterInDescTextField.getValue() );
construct.getUniverse().save();
construct.getUniverse().ddiStore = getEntityService().saveElement( construct.getUniverse(),
getDDIEditor().getCurrentUserId(), comment );
construct.getUniverse().setDdiStore( getEntityService().saveElement( construct.getUniverse(),
getDDIEditor().getCurrentUserId(), comment) );
}
private void storeMultipleQuestionItem( String comment )
......@@ -470,12 +470,12 @@ public class QuestionTranslateWindow extends BaseStoreCancelWindow implements Tr
if ( currentInterviewerRespondent != null && !currentInterviewerRespondent.getId().isEmpty() )
item.setInstructionReference( currentInterviewerRespondent.getId() );
item.save();
item.ddiStore = getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment );
item.setDdiStore( getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment ));
// CodeList codeList = item.getItemList();
// CategoryScheme categoryScheme = codeList.getCategoryScheme();
// categoryScheme.ddiStore = getEntityService().saveElement( categoryScheme,
// categoryScheme.setDdiStore( getEntityService().saveElement( categoryScheme,
// getDDIEditor().getCurrentUserId(), comment );
// codeList.ddiStore = getEntityService().saveElement( codeList, getDDIEditor().getCurrentUserId(),
// codeList.setDdiStore( getEntityService().saveElement( codeList, getDDIEditor().getCurrentUserId(),
// comment );
item.setLanguage( SOURCE_LANG );
}
......@@ -496,7 +496,7 @@ public class QuestionTranslateWindow extends BaseStoreCancelWindow implements Tr
if ( currentInterviewerRespondent != null && !currentInterviewerRespondent.getId().isEmpty() )
item.setInstructionReference( currentInterviewerRespondent.getId() );
item.save();
item.ddiStore = getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment );
item.setDdiStore( getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment ));
item.setLanguage( SOURCE_LANG );
}
......
......@@ -156,8 +156,8 @@ public class QuestionVariableWindow extends BaseStoreCancelWindow
variable.setEmbargo(cvAvailablityRef);
variable.save();
variable.ddiStore = questionWindow.getEntityService().saveElement( variable,
DDIEditorSecurityUtils.getLoggedUserName(), "save variable " + variable.getName() );
variable.setDdiStore( questionWindow.getEntityService().saveElement( variable,
DDIEditorSecurityUtils.getLoggedUserName(), "save variable " + variable.getName() ));
questionWindow.getEntityService()
.clearCacheForVariableByQuestionReference( questionWindow.getConstruct().getQuestionReference() );
questionWindow.updateVariableGrid();
......
......@@ -731,19 +731,19 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
// save categoryScheme
categoryScheme.save();
categoryScheme.ddiStore = getEntityService().saveElement( categoryScheme,
categoryScheme.setDdiStore( getEntityService().saveElement( categoryScheme,
DDIEditorSecurityUtils.getLoggedUserName(), "delete " +
DDIElement.CATEGORYSCHEME + " Code-Category: "
+ codeCategory.getCode().getValue() + " - "
+ codeCategory.getCategory().getText() );
+ codeCategory.getCategory().getText()) );
// save codelist
clist.save();
clist.ddiStore = getEntityService().saveElement( clist,
clist.setDdiStore( getEntityService().saveElement( clist,
DDIEditorSecurityUtils.getLoggedUserName(), "delete " +
DDIElement.CODELIST + " Code-Category: "
+ codeCategory.getCode().getValue() + " - "
+ codeCategory.getCategory().getText() );
+ codeCategory.getCategory().getText() ));
updateQuestionCodeCategoryGrid();
}
......@@ -938,10 +938,10 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
break;
}
this.entityService.deleteElement( instruction.ddiStore.getPrimaryKey(),
this.entityService.deleteElement( instruction.getDdiStore().getPrimaryKey(),
getUi().getCurrentUserId(),
"Instruction deleted:" + selectedInstruction.getLabel(),
instruction.ddiStore.getElementId() );
instruction.getDdiStore().getElementId() );
updateInstructionGrid( instructionType );
}
} );
......@@ -1274,8 +1274,8 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
entityService.insertConstructReference( construct.getId(), construct.getType(), masterSequence,
constructPrevSibling != null ? constructPrevSibling.getId() : null, comment );
construct.save();
construct.ddiStore = getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(),
comment );
construct.setDdiStore( getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(),
comment ));
}
......@@ -1332,10 +1332,10 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
construct.getUniverse().setUniverseCode( filterInTextField.getValue() );
construct.getUniverse().setDescription( filterInDescTextField.getValue() );
construct.getUniverse().save();
construct.getUniverse().ddiStore = getEntityService().saveElement( construct.getUniverse(),
getDDIEditor().getCurrentUserId(), comment );
construct.getUniverse().setDdiStore( getEntityService().saveElement( construct.getUniverse(),
getDDIEditor().getCurrentUserId(), comment ));
construct.save();
construct.ddiStore = getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(), comment );
construct.setDdiStore( getEntityService().saveElement( construct, getDDIEditor().getCurrentUserId(), comment ));
}
private void storeMultipleQuestionItem( String comment )
......@@ -1357,12 +1357,12 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
item.setRuntime( 0 );
CodeList codeList = item.getItemList();
CategoryScheme categoryScheme = codeList.getCategoryScheme();
categoryScheme.ddiStore = getEntityService().saveElement( categoryScheme,
getDDIEditor().getCurrentUserId(), comment );
codeList.ddiStore = getEntityService().saveElement( codeList, getDDIEditor().getCurrentUserId(),
comment );
categoryScheme.setDdiStore( getEntityService().saveElement( categoryScheme,
getDDIEditor().getCurrentUserId(), comment) );
codeList.setDdiStore( getEntityService().saveElement( codeList, getDDIEditor().getCurrentUserId(),
comment) );
item.save();
item.ddiStore = getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment );
item.setDdiStore( getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment ));
}
private void storeQuestionItem( String comment )
......@@ -1383,7 +1383,7 @@ public class QuestionWindow extends BaseStoreCancelWindow implements Translatabl
else
item.setRuntime( 0 );
item.save();
item.ddiStore = getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment );
item.setDdiStore( getEntityService().saveElement( item, getDDIEditor().getCurrentUserId(), comment ));
}
@Override
......
......@@ -114,9 +114,9 @@ public class StatementTranslateWindow extends BaseStoreCancelWindow
statement.setDescription( descriptionTlField.getValue() );
statement.setDisplayText( textTlField.getValue() );
statement.save();
statement.ddiStore = master.getEntityService().saveElement( statement,
statement.setDdiStore( master.getEntityService().saveElement( statement,
getDDIEditor().getCurrentUserId(),
comment );
comment ));
master.getEntityService().clearElementCacheForLists( statement.getContainerId(), DDIElement.STATEMENT );
statement.setLanguage( SOURCE_LANG );
......
......@@ -695,7 +695,7 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
editedInstrument.setLabel( args.get( EditStudyWindow.TITLE ).toString() );
editedInstrument.save();
entityService.getRestClient().saveElement( editedInstrument.ddiStore,
entityService.getRestClient().saveElement( editedInstrument.getDdiStore(),
DDIEditorSecurityUtils.getLoggedUserName(),
"Update study " + editedInstrument.getLabel() + " label: "
+ args.get( EditQuestionnaireWindow.COMMENT ) );
......@@ -747,7 +747,7 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
editedStudy.setTitle( args.get( EditStudyWindow.TITLE ).toString() );
editedStudy.save();
entityService.getRestClient().saveElement( editedStudy.ddiStore,
entityService.getRestClient().saveElement( editedStudy.getDdiStore(),
DDIEditorSecurityUtils.getLoggedUserName(),
"Update study " + editedStudy.getUserId() + " title: " + args.get( EditStudyWindow.COMMENT ) );
......
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