forked from sw360/sw360portal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sw360#395 from sw360/dev/projectReleaseRelationEnu…
…m#257 Convert Project To Relase Relations to Enums reviewed-by: [email protected] tested-by: [email protected]
- Loading branch information
Showing
41 changed files
with
454 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright Siemens AG, 2013-2016. Part of the SW360 Portal Project. | ||
* Copyright Siemens AG, 2013-2017. Part of the SW360 Portal Project. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
|
@@ -26,13 +26,16 @@ | |
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.eclipse.sw360.datahandler.common.CommonUtils.add; | ||
import static org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptyMap; | ||
import static org.eclipse.sw360.datahandler.common.CommonUtils.nullToEmptySet; | ||
|
||
/** | ||
* Class for comparing a document with its counterpart in the database | ||
* Writes the difference (= additions and deletions) to the moderation request | ||
* | ||
* @author [email protected] | ||
* @author [email protected] | ||
*/ | ||
public abstract class ModerationRequestGenerator<U extends TFieldIdEnum, T extends TBase<T, U>> { | ||
protected T documentAdditions; | ||
|
@@ -113,30 +116,28 @@ protected <S> void dealWithEnumMap(U field, Class<? extends TEnum> S) { | |
} | ||
} | ||
|
||
protected void dealWithStringMap(U field) { | ||
Map<String,String> addedMap = (Map<String, String>) updateDocument.getFieldValue(field); | ||
if(addedMap == null) { | ||
addedMap = new HashMap<>(); | ||
} | ||
Map<String,String> actualMap = (Map<String, String>) actualDocument.getFieldValue(field); | ||
for(Map.Entry<String, String> entry : actualMap.entrySet()){ | ||
addedMap.remove(entry); | ||
} | ||
protected void dealWithStringKeyedMap(U field) { | ||
Map<String, Object> addedMap = new HashMap<>(); | ||
addedMap.putAll(nullToEmptyMap((Map<String, Object>) updateDocument.getFieldValue(field))); | ||
|
||
Map<String,String> deletedMap = (Map<String, String>) actualDocument.getFieldValue(field); | ||
if (deletedMap == null) { | ||
deletedMap = new HashMap<>(); | ||
Map<String, Object> actualMap = (Map<String, Object>) actualDocument.getFieldValue(field); | ||
for(String key: actualMap.keySet()){ | ||
addedMap.remove(key); | ||
} | ||
Map<String,String> updateMap = (Map<String, String>) updateDocument.getFieldValue(field); | ||
for(Map.Entry<String, String> entry : updateMap.entrySet()){ | ||
deletedMap.remove(entry); | ||
|
||
Map<String, Object> deletedMap = new HashMap<>(); | ||
deletedMap.putAll(nullToEmptyMap((Map<String, Object>) actualDocument.getFieldValue(field))); | ||
|
||
Map<String, Object> updateMap = (Map<String, Object>) updateDocument.getFieldValue(field); | ||
for(String key : updateMap.keySet()){ | ||
deletedMap.remove(key); | ||
} | ||
|
||
//determine changes in common linkedProjects | ||
Set<String> commonKeys = Sets.intersection(updateMap.keySet(), actualMap.keySet()); | ||
for(String id : commonKeys) { | ||
String actual = actualMap.get(id); | ||
String update = updateMap.get(id); | ||
Object actual = actualMap.get(id); | ||
Object update = updateMap.get(id); | ||
if(! actual.equals(update)) { | ||
addedMap.put(id, update); | ||
deletedMap.put(id, actual); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.