Skip to content
Snippets Groups Projects
Commit 7a85f717 authored by buczekp's avatar buczekp
Browse files

[LMS-1761] changes in batch update of vocabulary terms

SVN: 17895
parent 42d55867
No related branches found
No related tags found
No related merge requests found
...@@ -1191,15 +1191,19 @@ public final class CommonClientService extends AbstractClientService implements ...@@ -1191,15 +1191,19 @@ public final class CommonClientService extends AbstractClientService implements
AbstractParserObjectFactory<VocabularyTerm> AbstractParserObjectFactory<VocabularyTerm>
{ {
private final VocabularyTermBatchUpdateDetails batchUpdateDetails; private final VocabularyTermBatchUpdateDetails basicBatchUpdateDetails;
protected UpdatedVocabularyTermObjectFactory(IPropertyMapper propertyMapper) protected UpdatedVocabularyTermObjectFactory(IPropertyMapper propertyMapper)
{ {
super(VocabularyTerm.class, propertyMapper); super(VocabularyTerm.class, propertyMapper);
this.batchUpdateDetails = createBatchUpdateDetails(); this.basicBatchUpdateDetails = createBasicBatchUpdateDetails();
} }
private VocabularyTermBatchUpdateDetails createBatchUpdateDetails() /**
* Prepares details about which values should be updated in general taking into account
* only the information about availability of columns in the file.
*/
private VocabularyTermBatchUpdateDetails createBasicBatchUpdateDetails()
{ {
boolean updateLabel = isColumnAvailable(UpdatedVocabularyTerm.LABEL); boolean updateLabel = isColumnAvailable(UpdatedVocabularyTerm.LABEL);
boolean updateDescription = isColumnAvailable(UpdatedVocabularyTerm.DESCRIPTION); boolean updateDescription = isColumnAvailable(UpdatedVocabularyTerm.DESCRIPTION);
...@@ -1209,8 +1213,43 @@ public final class CommonClientService extends AbstractClientService implements ...@@ -1209,8 +1213,43 @@ public final class CommonClientService extends AbstractClientService implements
@Override @Override
public VocabularyTerm createObject(String[] lineTokens) throws ParserException public VocabularyTerm createObject(String[] lineTokens) throws ParserException
{ {
final VocabularyTerm vocabularyTerm = super.createObject(lineTokens); final VocabularyTerm term = super.createObject(lineTokens);
return new UpdatedVocabularyTerm(vocabularyTerm, batchUpdateDetails); final VocabularyTermBatchUpdateDetails updateDetails =
createBatchUpdateDetails(term);
cleanUp(term);
return new UpdatedVocabularyTerm(term, updateDetails);
}
//
// handle empty values and deletion
//
/**
* Returns details about which values should be updated for the specified term. If a
* cell was left empty in the file the corresponding value will not be modified.
*/
private VocabularyTermBatchUpdateDetails createBatchUpdateDetails(VocabularyTerm term)
{
final boolean updateLabel =
basicBatchUpdateDetails.isLabelUpdateRequested()
&& isNotEmpty(term.getLabel());
final boolean updateDescription =
basicBatchUpdateDetails.isDescriptionUpdateRequested()
&& isNotEmpty(term.getDescription());
return new VocabularyTermBatchUpdateDetails(updateLabel, updateDescription);
}
/** Cleans properties of the specified term that are marked for deletion. */
private void cleanUp(VocabularyTerm term)
{
if (isDeletionMark(term.getLabel()))
{
term.setLabel(null);
}
if (isDeletionMark(term.getDescription()))
{
term.setDescription(null);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment