aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-conflict-lib
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-conflict-lib
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-conflict-lib')
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java24
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java19
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java14
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java10
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java45
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java64
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java46
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java43
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java7
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java45
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java18
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java261
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java84
-rw-r--r--openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java298
14 files changed, 462 insertions, 516 deletions
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java
index c0947d0b69..16ad7b274a 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandler.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,31 +17,27 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts;
+import java.util.Optional;
import org.openecomp.conflicts.types.Conflict;
import org.openecomp.conflicts.types.ConflictResolution;
import org.openecomp.conflicts.types.ItemVersionConflict;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Optional;
-
public interface ItemMergeHandler {
- boolean isConflicted(String itemId, Version version);
+ boolean isConflicted(String itemId, Version version);
- void finalizeMerge(String itemId, Version version);
+ void finalizeMerge(String itemId, Version version);
- void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts);
+ void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts);
- Optional<Conflict> getConflict(String itemId, Version version, String conflictId);
+ Optional<Conflict> getConflict(String itemId, Version version, String conflictId);
- void postGetConflict(String itemId, Version version, Conflict conflict);
+ void postGetConflict(String itemId, Version version, Conflict conflict);
- void preResolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution);
+ void preResolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution);
- boolean resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution);
+ boolean resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution);
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java
index d309e6f8fa..209ce16e44 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactory.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,20 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts;
+import java.util.Optional;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-import java.util.Optional;
-
-public abstract class ItemMergeHandlerFactory
- extends AbstractComponentFactory<ItemMergeHandler> {
+public abstract class ItemMergeHandlerFactory extends AbstractComponentFactory<ItemMergeHandler> {
- public static ItemMergeHandlerFactory getInstance() {
- return AbstractFactory.getInstance(ItemMergeHandlerFactory.class);
- }
+ public static ItemMergeHandlerFactory getInstance() {
+ return AbstractFactory.getInstance(ItemMergeHandlerFactory.class);
+ }
- public abstract Optional<ItemMergeHandler> createInterface(String itemId);
+ public abstract Optional<ItemMergeHandler> createInterface(String itemId);
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java
index 20865efc08..a3264e100f 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDao.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.dao;
import org.openecomp.conflicts.types.Conflict;
@@ -27,12 +26,11 @@ import org.openecomp.sdc.versioning.dao.types.Version;
public interface ConflictsDao {
- boolean isConflicted(String itemId, Version version);
+ boolean isConflicted(String itemId, Version version);
- ItemVersionConflict getConflict(String itemId, Version version);
+ ItemVersionConflict getConflict(String itemId, Version version);
- Conflict getConflict(String itemId, Version version, String conflictId);
+ Conflict getConflict(String itemId, Version version, String conflictId);
- void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution conflictResolution);
+ void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution conflictResolution);
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
index e4c88d6279..3c4525e1aa 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/dao/ConflictsDaoFactory.java
@@ -17,16 +17,14 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.dao;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
-public abstract class ConflictsDaoFactory
- extends AbstractComponentFactory<ConflictsDao> {
+public abstract class ConflictsDaoFactory extends AbstractComponentFactory<ConflictsDao> {
- public static ConflictsDaoFactory getInstance() {
- return AbstractFactory.getInstance(ConflictsDaoFactory.class);
- }
+ public static ConflictsDaoFactory getInstance() {
+ return AbstractFactory.getInstance(ConflictsDaoFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java
index 80186f876b..33b2026628 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Conflict.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,38 +17,37 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.types;
import com.google.common.annotations.VisibleForTesting;
import org.openecomp.sdc.datatypes.model.ElementType;
public class Conflict<T> extends ConflictInfo {
- private T yours;
- private T theirs;
-
- @VisibleForTesting
- Conflict() {}
- public Conflict(String id, ElementType type, String name) {
- super(id, type, name);
- }
+ private T yours;
+ private T theirs;
- public T getYours() {
- return yours;
- }
+ @VisibleForTesting
+ Conflict() {
+ }
- public void setYours(T yours) {
- this.yours = yours;
- }
+ public Conflict(String id, ElementType type, String name) {
+ super(id, type, name);
+ }
- public T getTheirs() {
- return theirs;
- }
+ public T getYours() {
+ return yours;
+ }
- public void setTheirs(T theirs) {
- this.theirs = theirs;
- }
+ public void setYours(T yours) {
+ this.yours = yours;
+ }
+ public T getTheirs() {
+ return theirs;
+ }
+ public void setTheirs(T theirs) {
+ this.theirs = theirs;
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java
index af4111c1dd..b56b576eb7 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictInfo.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,48 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.types;
import com.google.common.annotations.VisibleForTesting;
import org.openecomp.sdc.datatypes.model.ElementType;
public class ConflictInfo {
- private String id;
- private ElementType type;
- private String name;
- @VisibleForTesting
- ConflictInfo() {
- }
+ private String id;
+ private ElementType type;
+ private String name;
+
+ @VisibleForTesting
+ ConflictInfo() {
+ }
- public ConflictInfo(String id, ElementType type, String name) {
- this.id = id;
- this.type = type;
- this.name = name;
- }
+ public ConflictInfo(String id, ElementType type, String name) {
+ this.id = id;
+ this.type = type;
+ this.name = name;
+ }
- public String getId() {
- return id;
- }
+ public String getId() {
+ return id;
+ }
- public void setId(String id) {
- this.id = id;
- }
+ public void setId(String id) {
+ this.id = id;
+ }
- public ElementType getType() {
- return type;
- }
+ public ElementType getType() {
+ return type;
+ }
- public void setType(ElementType type) {
- this.type = type;
- }
+ public void setType(ElementType type) {
+ this.type = type;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java
index 04a790ca91..05387c6baf 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ConflictResolution.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,36 +17,36 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.types;
import java.util.Map;
public class ConflictResolution {
- private Resolution resolution;
- // sits in lower level...
- private Map<String, Object> otherResolution;
- public ConflictResolution() {
- }
+ private Resolution resolution;
+ // sits in lower level...
+ private Map<String, Object> otherResolution;
+
+ public ConflictResolution() {
+ }
- public ConflictResolution(Resolution resolution) {
- this.resolution = resolution;
- }
+ public ConflictResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
- public Resolution getResolution() {
- return resolution;
- }
+ public Resolution getResolution() {
+ return resolution;
+ }
- public void setResolution(Resolution resolution) {
- this.resolution = resolution;
- }
+ public void setResolution(Resolution resolution) {
+ this.resolution = resolution;
+ }
- public Map<String, Object> getOtherResolution() {
- return otherResolution;
- }
+ public Map<String, Object> getOtherResolution() {
+ return otherResolution;
+ }
- public void setOtherResolution(Map<String, Object> otherResolution) {
- this.otherResolution = otherResolution;
- }
+ public void setOtherResolution(Map<String, Object> otherResolution) {
+ this.otherResolution = otherResolution;
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java
index 4ae2b2c086..4bd3eabc7e 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/ItemVersionConflict.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,35 +17,34 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.types;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
import java.util.ArrayList;
import java.util.Collection;
+import org.openecomp.sdc.versioning.dao.types.Version;
public class ItemVersionConflict {
- private Conflict<Version> versionConflict;
- private Collection<ConflictInfo> elementConflicts = new ArrayList<>();
- public Conflict<Version> getVersionConflict() {
- return versionConflict;
- }
+ private Conflict<Version> versionConflict;
+ private Collection<ConflictInfo> elementConflicts = new ArrayList<>();
+
+ public Conflict<Version> getVersionConflict() {
+ return versionConflict;
+ }
- public void setVersionConflict(Conflict<Version> versionConflict) {
- this.versionConflict = versionConflict;
- }
+ public void setVersionConflict(Conflict<Version> versionConflict) {
+ this.versionConflict = versionConflict;
+ }
- public Collection<ConflictInfo> getElementConflicts() {
- return elementConflicts;
- }
+ public Collection<ConflictInfo> getElementConflicts() {
+ return elementConflicts;
+ }
- public void setElementConflicts(Collection<ConflictInfo> elementConflicts) {
- this.elementConflicts = elementConflicts;
- }
+ public void setElementConflicts(Collection<ConflictInfo> elementConflicts) {
+ this.elementConflicts = elementConflicts;
+ }
- public void addElementConflictInfo(ConflictInfo conflictInfo) {
- elementConflicts.add(conflictInfo);
- }
+ public void addElementConflictInfo(ConflictInfo conflictInfo) {
+ elementConflicts.add(conflictInfo);
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java
index 5f7db39486..2f03dbe9d8 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-api/src/main/java/org/openecomp/conflicts/types/Resolution.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.types;
public enum Resolution {
- THEIRS,YOURS,OTHER
+ THEIRS, YOURS, OTHER
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java
index 3c879dee17..bff46a81fa 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/ItemMergeHandlerFactoryImpl.java
@@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.conflicts;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
import org.openecomp.conflicts.dao.ConflictsDaoFactory;
import org.openecomp.conflicts.impl.VspMergeHandler;
import org.openecomp.sdc.common.errors.CoreException;
@@ -25,32 +27,27 @@ import org.openecomp.sdc.versioning.AsdcItemManagerFactory;
import org.openecomp.sdc.versioning.errors.EntityNotExistErrorBuilder;
import org.openecomp.sdc.versioning.types.Item;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
public class ItemMergeHandlerFactoryImpl extends ItemMergeHandlerFactory {
- // TODO: 11/1/2017 read this map from configuration, move Vsp merge handler to vsp lib, rearrange lib deps
- private static final Map<ItemType, ItemMergeHandler> MERGE_HANDLER_BY_ITEM_TYPE =
- new HashMap<>();
- static {
- MERGE_HANDLER_BY_ITEM_TYPE.put(ItemType.vsp,
- new VspMergeHandler(ConflictsDaoFactory.getInstance().createInterface(),
- VspMergeDaoFactory.getInstance().createInterface()));
- }
+ // TODO: 11/1/2017 read this map from configuration, move Vsp merge handler to vsp lib, rearrange lib deps
+ private static final Map<ItemType, ItemMergeHandler> MERGE_HANDLER_BY_ITEM_TYPE = new HashMap<>();
- @Override
- public Optional<ItemMergeHandler> createInterface(String itemId) {
- Item item = AsdcItemManagerFactory.getInstance().createInterface().get(itemId);
- if (item == null) {
- throw new CoreException(new EntityNotExistErrorBuilder("", itemId).build());
+ static {
+ MERGE_HANDLER_BY_ITEM_TYPE.put(ItemType.vsp,
+ new VspMergeHandler(ConflictsDaoFactory.getInstance().createInterface(), VspMergeDaoFactory.getInstance().createInterface()));
}
- return Optional.ofNullable(MERGE_HANDLER_BY_ITEM_TYPE.get(ItemType.valueOf(item.getType())));
- }
- @Override
- public ItemMergeHandler createInterface() {
- return null; // call the one with the item id arg
- }
+ @Override
+ public Optional<ItemMergeHandler> createInterface(String itemId) {
+ Item item = AsdcItemManagerFactory.getInstance().createInterface().get(itemId);
+ if (item == null) {
+ throw new CoreException(new EntityNotExistErrorBuilder("", itemId).build());
+ }
+ return Optional.ofNullable(MERGE_HANDLER_BY_ITEM_TYPE.get(ItemType.valueOf(item.getType())));
+ }
+
+ @Override
+ public ItemMergeHandler createInterface() {
+ return null; // call the one with the item id arg
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java
index 1ae13b8c48..61a1e18c45 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoFactoryImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.dao.impl.zusammen;
-
import org.openecomp.conflicts.dao.ConflictsDao;
import org.openecomp.conflicts.dao.ConflictsDaoFactory;
import org.openecomp.core.zusammen.api.ZusammenAdaptorFactory;
@@ -28,11 +26,11 @@ import org.openecomp.core.zusammen.api.ZusammenUtil;
public class ConflictsDaoFactoryImpl extends ConflictsDaoFactory {
- private static final ConflictsDao INSTANCE = new
- ConflictsDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface(), ZusammenUtil::createSessionContext);
+ private static final ConflictsDao INSTANCE = new ConflictsDaoImpl(ZusammenAdaptorFactory.getInstance().createInterface(),
+ ZusammenUtil::createSessionContext);
- @Override
- public ConflictsDao createInterface() {
- return INSTANCE;
- }
+ @Override
+ public ConflictsDao createInterface() {
+ return INSTANCE;
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java
index ecc0a3c7ab..047d5c2743 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ConflictsDaoImpl.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.dao.impl.zusammen;
+import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
+
import com.amdocs.zusammen.adaptor.inbound.api.types.item.Element;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflict;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
@@ -37,145 +38,149 @@ import org.openecomp.conflicts.types.ItemVersionConflict;
import org.openecomp.convertor.ElementConvertor;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.sdc.datatypes.model.ElementType;
-import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.*;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.*;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToEntitlementPoolConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToFeatureGroupConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseAgreementConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLicenseKeyGroupConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToLimitConvertor;
+import org.openecomp.sdc.vendorlicense.dao.impl.zusammen.convertor.ElementToVLMGeneralConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComponentDependencyModelConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToCompositionEntityConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToComputeConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToImageConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToMonitoringUploadMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNetworkConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToNicConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToOrchestrationTemplateCandidateMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToProcessConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToServiceModelMapConvertor;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.impl.zusammen.convertor.ElementToVSPGeneralConvertor;
import org.openecomp.sdc.versioning.dao.types.Version;
-import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
-
public class ConflictsDaoImpl implements ConflictsDao {
- private final ZusammenAdaptor zusammenAdaptor;
- private final Supplier<SessionContext> sessionContextProvider;
-
- public ConflictsDaoImpl(ZusammenAdaptor zusammenAdaptor, Supplier<SessionContext> sessionContextProvider) {
- this.zusammenAdaptor = zusammenAdaptor;
- this.sessionContextProvider = sessionContextProvider;
- }
-
- @Override
- public boolean isConflicted(String itemId, Version version) {
- com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict itemVersionConflict =
- zusammenAdaptor
- .getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId()));
- return !(itemVersionConflict == null
- || (itemVersionConflict.getVersionDataConflict() == null
- && itemVersionConflict.getElementConflictInfos().isEmpty()));
- }
-
- @Override
- public ItemVersionConflict getConflict(String itemId, Version version) {
- return new ItemVersionConflictConvertorFromZusammen().convert(itemId, version,
- zusammenAdaptor
- .getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId())));
- }
-
- @Override
- public Conflict getConflict(String itemId, Version version, String conflictId) {
- return zusammenAdaptor.getElementConflict(sessionContextProvider.get(),
- new ElementContext(new Id(itemId), new Id(version.getId())), new Id(conflictId))
- .map(elementConflict -> convertElementConflict(conflictId, elementConflict))
- .orElse(null);
- }
-
- @Override
- public void resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution conflictResolution) {
- SessionContext context = sessionContextProvider.get();
- ElementContext elementContext = new ElementContext(new Id(itemId), new Id(version.getId()));
-
- // TODO: 7/31/2017 when 'OTHER' resolution will be supported - populate zusammen element with it
- zusammenAdaptor.resolveElementConflict(context, elementContext,
- buildElement(new Id(conflictId), null),
- Resolution.valueOf(conflictResolution.getResolution().name()));
- }
-
- private Conflict convertElementConflict(String conflictId, ElementConflict elementConflict) {
- Element element = elementConflict.getLocalElement() == null
- ? elementConflict.getRemoteElement()
- : elementConflict.getLocalElement();
- ElementType elementType = ElementConvertor.getElementType(element);
-
- Conflict conflict =
- new Conflict(conflictId, elementType, ElementConvertor.getElementName(element));
- ElementConvertor convertor = getConvertor(elementType);
- if (elementConflict.getLocalElement() != null) {
- conflict.setYours(convertor.convert(elementConflict.getLocalElement()));
- }
- if (elementConflict.getRemoteElement() != null) {
- conflict.setTheirs(convertor.convert(elementConflict.getRemoteElement()));
- }
- return conflict;
- }
-
- private ElementConvertor getConvertor(ElementType type) {
- switch (type) {
- case VendorSoftwareProduct:
- return new ElementToVSPGeneralConvertor();
- case Process:
- return new ElementToProcessConvertor();
- case Nic:
- return new ElementToNicConvertor();
- case Network:
- return new ElementToNetworkConvertor();
- case SNMP_POLL:
- case SNMP_TRAP:
- case VES_EVENTS:
- return new ElementToMonitoringUploadMapConvertor();
- case Image:
- return new ElementToImageConvertor();
- case Compute:
- return new ElementToComputeConvertor();
- case Component:
- return new ElementToComponentConvertor();
- case ComponentDependencies:
- return new ElementToComponentDependencyModelConvertor();
- case VendorLicenseModel:
- return new ElementToVLMGeneralConvertor();
- case LicenseAgreement:
- return new ElementToLicenseAgreementConvertor();
- case FeatureGroup:
- return new ElementToFeatureGroupConvertor();
- case LicenseKeyGroup:
- return new ElementToLicenseKeyGroupConvertor();
- case EntitlementPool:
- return new ElementToEntitlementPoolConvertor();
- case Limit:
- return new ElementToLimitConvertor();
- case OrchestrationTemplateCandidate:
- return new ElementToOrchestrationTemplateCandidateMapConvertor();
- case ServiceModel:
- return new ElementToServiceModelMapConvertor();
- case VSPQuestionnaire:
- case ImageQuestionnaire:
- case ComponentQuestionnaire:
- case ComputeQuestionnaire:
- case NicQuestionnaire:
- return new ElementToCompositionEntityConvertor();
- default:
- return new EchoConvertor();
- }
- }
- public static class EchoConvertor extends ElementConvertor {
+ private final ZusammenAdaptor zusammenAdaptor;
+ private final Supplier<SessionContext> sessionContextProvider;
+
+ public ConflictsDaoImpl(ZusammenAdaptor zusammenAdaptor, Supplier<SessionContext> sessionContextProvider) {
+ this.zusammenAdaptor = zusammenAdaptor;
+ this.sessionContextProvider = sessionContextProvider;
+ }
@Override
- public Object convert(Element element) {
- return element;
+ public boolean isConflicted(String itemId, Version version) {
+ com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict itemVersionConflict = zusammenAdaptor
+ .getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId()));
+ return !(itemVersionConflict == null || (itemVersionConflict.getVersionDataConflict() == null && itemVersionConflict.getElementConflictInfos()
+ .isEmpty()));
}
@Override
- public Object convert(Item item) {
- return item;
+ public ItemVersionConflict getConflict(String itemId, Version version) {
+ return new ItemVersionConflictConvertorFromZusammen()
+ .convert(itemId, version, zusammenAdaptor.getVersionConflict(sessionContextProvider.get(), new Id(itemId), new Id(version.getId())));
}
@Override
- public Object convert(ElementInfo elementInfo) {
- return elementInfo;
+ public Conflict getConflict(String itemId, Version version, String conflictId) {
+ return zusammenAdaptor
+ .getElementConflict(sessionContextProvider.get(), new ElementContext(new Id(itemId), new Id(version.getId())), new Id(conflictId))
+ .map(elementConflict -> convertElementConflict(conflictId, elementConflict)).orElse(null);
}
@Override
- public Object convert(ItemVersion itemVersion) {
- return null;
+ public void resolveConflict(String itemId, Version version, String conflictId, ConflictResolution conflictResolution) {
+ SessionContext context = sessionContextProvider.get();
+ ElementContext elementContext = new ElementContext(new Id(itemId), new Id(version.getId()));
+ // TODO: 7/31/2017 when 'OTHER' resolution will be supported - populate zusammen element with it
+ zusammenAdaptor.resolveElementConflict(context, elementContext, buildElement(new Id(conflictId), null),
+ Resolution.valueOf(conflictResolution.getResolution().name()));
+ }
+
+ private Conflict convertElementConflict(String conflictId, ElementConflict elementConflict) {
+ Element element = elementConflict.getLocalElement() == null ? elementConflict.getRemoteElement() : elementConflict.getLocalElement();
+ ElementType elementType = ElementConvertor.getElementType(element);
+ Conflict conflict = new Conflict(conflictId, elementType, ElementConvertor.getElementName(element));
+ ElementConvertor convertor = getConvertor(elementType);
+ if (elementConflict.getLocalElement() != null) {
+ conflict.setYours(convertor.convert(elementConflict.getLocalElement()));
+ }
+ if (elementConflict.getRemoteElement() != null) {
+ conflict.setTheirs(convertor.convert(elementConflict.getRemoteElement()));
+ }
+ return conflict;
+ }
+
+ private ElementConvertor getConvertor(ElementType type) {
+ switch (type) {
+ case VendorSoftwareProduct:
+ return new ElementToVSPGeneralConvertor();
+ case Process:
+ return new ElementToProcessConvertor();
+ case Nic:
+ return new ElementToNicConvertor();
+ case Network:
+ return new ElementToNetworkConvertor();
+ case SNMP_POLL:
+ case SNMP_TRAP:
+ case VES_EVENTS:
+ return new ElementToMonitoringUploadMapConvertor();
+ case Image:
+ return new ElementToImageConvertor();
+ case Compute:
+ return new ElementToComputeConvertor();
+ case Component:
+ return new ElementToComponentConvertor();
+ case ComponentDependencies:
+ return new ElementToComponentDependencyModelConvertor();
+ case VendorLicenseModel:
+ return new ElementToVLMGeneralConvertor();
+ case LicenseAgreement:
+ return new ElementToLicenseAgreementConvertor();
+ case FeatureGroup:
+ return new ElementToFeatureGroupConvertor();
+ case LicenseKeyGroup:
+ return new ElementToLicenseKeyGroupConvertor();
+ case EntitlementPool:
+ return new ElementToEntitlementPoolConvertor();
+ case Limit:
+ return new ElementToLimitConvertor();
+ case OrchestrationTemplateCandidate:
+ return new ElementToOrchestrationTemplateCandidateMapConvertor();
+ case ServiceModel:
+ return new ElementToServiceModelMapConvertor();
+ case VSPQuestionnaire:
+ case ImageQuestionnaire:
+ case ComponentQuestionnaire:
+ case ComputeQuestionnaire:
+ case NicQuestionnaire:
+ return new ElementToCompositionEntityConvertor();
+ default:
+ return new EchoConvertor();
+ }
+ }
+
+ public static class EchoConvertor extends ElementConvertor {
+
+ @Override
+ public Object convert(Element element) {
+ return element;
+ }
+
+ @Override
+ public Object convert(Item item) {
+ return item;
+ }
+
+ @Override
+ public Object convert(ElementInfo elementInfo) {
+ return elementInfo;
+ }
+
+ @Override
+ public Object convert(ItemVersion itemVersion) {
+ return null;
+ }
}
- }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java
index 67827bc041..9c5238c44e 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/dao/impl/zusammen/ItemVersionConflictConvertorFromZusammen.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,10 +17,8 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.dao.impl.zusammen;
-
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementConflictInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ElementInfo;
import com.amdocs.zusammen.adaptor.inbound.api.types.item.ItemVersionConflict;
@@ -28,6 +26,7 @@ import com.amdocs.zusammen.datatypes.Id;
import com.amdocs.zusammen.datatypes.item.ItemVersion;
import com.amdocs.zusammen.datatypes.item.ItemVersionData;
import com.amdocs.zusammen.datatypes.item.ItemVersionDataConflict;
+import java.util.stream.Collectors;
import org.openecomp.conflicts.types.Conflict;
import org.openecomp.conflicts.types.ConflictInfo;
import org.openecomp.sdc.datatypes.model.ElementType;
@@ -35,59 +34,40 @@ import org.openecomp.sdc.versioning.dao.impl.zusammen.convertor.ItemVersionToVer
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.types.ElementPropertyName;
-import java.util.stream.Collectors;
-
public class ItemVersionConflictConvertorFromZusammen {
- public org.openecomp.conflicts.types.ItemVersionConflict convert(String itemId, Version version,
- ItemVersionConflict source) {
- org.openecomp.conflicts.types.ItemVersionConflict target =
- new org.openecomp.conflicts.types.ItemVersionConflict();
-
- target.setVersionConflict(
- convertVersionDataConflict(itemId, version, source.getVersionDataConflict()));
- target.setElementConflicts(source.getElementConflictInfos().stream()
- .map(this::convertElementConflictInfo)
- .collect(Collectors.toList()));
- return target;
- }
-
-
- private Conflict<Version> convertVersionDataConflict(String itemId, Version version,
- ItemVersionDataConflict versionDataConflict) {
- if (versionDataConflict == null) {
- return null;
+ public org.openecomp.conflicts.types.ItemVersionConflict convert(String itemId, Version version, ItemVersionConflict source) {
+ org.openecomp.conflicts.types.ItemVersionConflict target = new org.openecomp.conflicts.types.ItemVersionConflict();
+ target.setVersionConflict(convertVersionDataConflict(itemId, version, source.getVersionDataConflict()));
+ target.setElementConflicts(source.getElementConflictInfos().stream().map(this::convertElementConflictInfo).collect(Collectors.toList()));
+ return target;
}
- Conflict<Version> conflict =
- new Conflict<>(version.getId(), ElementType.itemVersion, null);
-
- ItemVersionToVersionConvertor convertor = new ItemVersionToVersionConvertor();
- conflict.setYours(convertor.convert(
- getItemVersion(version.getId(), versionDataConflict.getLocalData())));
- conflict.setTheirs(convertor.convert(
- getItemVersion(version.getId(), versionDataConflict.getRemoteData())));
- return conflict;
- }
-
- private ItemVersion getItemVersion(String versionId, ItemVersionData versionData) {
- if (versionData == null) {
- return null;
+ private Conflict<Version> convertVersionDataConflict(String itemId, Version version, ItemVersionDataConflict versionDataConflict) {
+ if (versionDataConflict == null) {
+ return null;
+ }
+ Conflict<Version> conflict = new Conflict<>(version.getId(), ElementType.itemVersion, null);
+ ItemVersionToVersionConvertor convertor = new ItemVersionToVersionConvertor();
+ conflict.setYours(convertor.convert(getItemVersion(version.getId(), versionDataConflict.getLocalData())));
+ conflict.setTheirs(convertor.convert(getItemVersion(version.getId(), versionDataConflict.getRemoteData())));
+ return conflict;
}
- ItemVersion itemVersion = new ItemVersion();
- itemVersion.setId(new Id(versionId));
- itemVersion.setData(versionData);
- return itemVersion;
- }
- private ConflictInfo convertElementConflictInfo(ElementConflictInfo elementConflictInfo) {
- ElementInfo elementInfo = elementConflictInfo.getLocalElementInfo() == null
- ? elementConflictInfo.getRemoteElementInfo()
- : elementConflictInfo.getLocalElementInfo();
+ private ItemVersion getItemVersion(String versionId, ItemVersionData versionData) {
+ if (versionData == null) {
+ return null;
+ }
+ ItemVersion itemVersion = new ItemVersion();
+ itemVersion.setId(new Id(versionId));
+ itemVersion.setData(versionData);
+ return itemVersion;
+ }
- return new ConflictInfo(elementInfo.getId().getValue(),
- ElementType
- .valueOf(elementInfo.getInfo().getProperty(ElementPropertyName.elementType.name())),
- elementInfo.getInfo().getName());
- }
+ private ConflictInfo convertElementConflictInfo(ElementConflictInfo elementConflictInfo) {
+ ElementInfo elementInfo = elementConflictInfo.getLocalElementInfo() == null ? elementConflictInfo.getRemoteElementInfo()
+ : elementConflictInfo.getLocalElementInfo();
+ return new ConflictInfo(elementInfo.getId().getValue(),
+ ElementType.valueOf(elementInfo.getInfo().getProperty(ElementPropertyName.elementType.name())), elementInfo.getInfo().getName());
+ }
}
diff --git a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
index 17b3043472..f3ea1eec87 100644
--- a/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
+++ b/openecomp-be/lib/openecomp-conflict-lib/openecomp-conflict-core/src/main/java/org/openecomp/conflicts/impl/VspMergeHandler.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,12 +17,33 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.conflicts.impl;
+import static org.openecomp.sdc.datatypes.model.ElementType.NetworkPackage;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplate;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateCandidate;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateCandidateContent;
+import static org.openecomp.sdc.datatypes.model.ElementType.OrchestrationTemplateValidationData;
+import static org.openecomp.sdc.datatypes.model.ElementType.VspModel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.openecomp.conflicts.ItemMergeHandler;
import org.openecomp.conflicts.dao.ConflictsDao;
-import org.openecomp.conflicts.types.*;
+import org.openecomp.conflicts.types.Conflict;
+import org.openecomp.conflicts.types.ConflictInfo;
+import org.openecomp.conflicts.types.ConflictResolution;
+import org.openecomp.conflicts.types.ItemVersionConflict;
+import org.openecomp.conflicts.types.Resolution;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
@@ -30,179 +51,138 @@ import org.openecomp.sdc.datatypes.model.ElementType;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
+public class VspMergeHandler implements ItemMergeHandler {
-import static org.openecomp.sdc.datatypes.model.ElementType.*;
+ private static final String VSP_MODEL_CONFLICT_ID = "vspModelConflictId";
+ private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
+ private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG = "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
+ private static final Set<ElementType> FILTERED_OUT_TYPES = Stream.of(OrchestrationTemplateCandidateContent, OrchestrationTemplateValidationData)
+ .collect(Collectors.toSet());
+ private static final Map<ElementType, Set<ElementType>> ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES = new EnumMap<>(ElementType.class);
-public class VspMergeHandler implements ItemMergeHandler {
+ static {
+ ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplateCandidate, Collections.singleton(OrchestrationTemplateCandidateContent));
+ ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplate, Collections.singleton(OrchestrationTemplateValidationData));
+ }
+
+ private ConflictsDao conflictsDao;
+ private VspMergeDao vspMergeDao;
- private static final String VSP_MODEL_CONFLICT_ID = "vspModelConflictId";
- private static final String ELEMENT_CONFLICT_NOT_EXIST_ERR_ID = "ELEMENT_CONFLICT_NOT_EXIST";
- private static final String ELEMENT_CONFLICT_NOT_EXISTS_MSG =
- "Item Id %s, version Id %s, element conflict with Id %s does not exists.";
- private static final Set<ElementType> FILTERED_OUT_TYPES = Stream
- .of(OrchestrationTemplateCandidateContent, OrchestrationTemplateValidationData)
- .collect(Collectors.toSet());
- private static final Map<ElementType, Set<ElementType>> ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES =
- new EnumMap<>(ElementType.class);
-
- static {
- ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplateCandidate,
- Collections.singleton(OrchestrationTemplateCandidateContent));
- ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.put(OrchestrationTemplate,
- Collections.singleton(OrchestrationTemplateValidationData));
- }
-
- private ConflictsDao conflictsDao;
- private VspMergeDao vspMergeDao;
-
- public VspMergeHandler(ConflictsDao conflictsDao, VspMergeDao vspMergeDao) {
- this.conflictsDao = conflictsDao;
- this.vspMergeDao = vspMergeDao;
- }
-
- @Override
- public boolean isConflicted(String itemId, Version version) {
- return vspMergeDao.isConflicted(itemId, version);
- }
-
- @Override
- public void finalizeMerge(String itemId, Version version) {
- if (!conflictsDao.isConflicted(itemId, version)) {
- vspMergeDao.applyConflictResolution(itemId, version);
+ public VspMergeHandler(ConflictsDao conflictsDao, VspMergeDao vspMergeDao) {
+ this.conflictsDao = conflictsDao;
+ this.vspMergeDao = vspMergeDao;
}
- }
-
- @Override
- public void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts) {
- List<ConflictInfo> elementConflicts = new ArrayList<>();
-
- boolean vspModelConflicted = false;
- for (ConflictInfo elementConflict : conflicts.getElementConflicts()) {
- if (elementConflict.getType() == VspModel) {
- elementConflicts.add(
- new ConflictInfo(elementConflict.getId(), NetworkPackage, NetworkPackage.name()));
- vspModelConflicted = true;
- continue;
- }
- if (!FILTERED_OUT_TYPES.contains(elementConflict.getType())) {
- elementConflicts.add(elementConflict);
- }
+
+ @Override
+ public boolean isConflicted(String itemId, Version version) {
+ return vspMergeDao.isConflicted(itemId, version);
+ }
+
+ @Override
+ public void finalizeMerge(String itemId, Version version) {
+ if (!conflictsDao.isConflicted(itemId, version)) {
+ vspMergeDao.applyConflictResolution(itemId, version);
+ }
}
- if (!vspModelConflicted && vspMergeDao.isConflicted(itemId, version)) {
- elementConflicts
- .add(new ConflictInfo(VSP_MODEL_CONFLICT_ID, NetworkPackage, NetworkPackage.name()));
+ @Override
+ public void postListConflicts(String itemId, Version version, ItemVersionConflict conflicts) {
+ List<ConflictInfo> elementConflicts = new ArrayList<>();
+ boolean vspModelConflicted = false;
+ for (ConflictInfo elementConflict : conflicts.getElementConflicts()) {
+ if (elementConflict.getType() == VspModel) {
+ elementConflicts.add(new ConflictInfo(elementConflict.getId(), NetworkPackage, NetworkPackage.name()));
+ vspModelConflicted = true;
+ continue;
+ }
+ if (!FILTERED_OUT_TYPES.contains(elementConflict.getType())) {
+ elementConflicts.add(elementConflict);
+ }
+ }
+ if (!vspModelConflicted && vspMergeDao.isConflicted(itemId, version)) {
+ elementConflicts.add(new ConflictInfo(VSP_MODEL_CONFLICT_ID, NetworkPackage, NetworkPackage.name()));
+ }
+ conflicts.setElementConflicts(elementConflicts);
}
- conflicts.setElementConflicts(elementConflicts);
- }
-
- @Override
- public Optional<Conflict> getConflict(String itemId, Version version, String conflictId) {
- return VSP_MODEL_CONFLICT_ID.equals(conflictId)
- ? Optional.of(buildVspModelConflict(conflictId))
- : Optional.empty();
- }
-
- @Override
- public void postGetConflict(String itemId, Version version, Conflict conflict) {
- if (conflict.getType() == VspModel) {
- Conflict vspModelConflict = buildVspModelConflict(null);
- conflict.setType(vspModelConflict.getType());
- conflict.setName(vspModelConflict.getName());
- conflict.setYours(vspModelConflict.getYours());
- conflict.setTheirs(vspModelConflict.getTheirs());
+ @Override
+ public Optional<Conflict> getConflict(String itemId, Version version, String conflictId) {
+ return VSP_MODEL_CONFLICT_ID.equals(conflictId) ? Optional.of(buildVspModelConflict(conflictId)) : Optional.empty();
}
- }
- @Override
- public void preResolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution) {
- if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
- return;
+ @Override
+ public void postGetConflict(String itemId, Version version, Conflict conflict) {
+ if (conflict.getType() == VspModel) {
+ Conflict vspModelConflict = buildVspModelConflict(null);
+ conflict.setType(vspModelConflict.getType());
+ conflict.setName(vspModelConflict.getName());
+ conflict.setYours(vspModelConflict.getYours());
+ conflict.setTheirs(vspModelConflict.getTheirs());
+ }
}
- resolveDependantConflicts(itemId, version, conflictId, resolution);
- }
-
- @Override
- public boolean resolveConflict(String itemId, Version version, String conflictId,
- ConflictResolution resolution) {
- if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
- vspMergeDao.updateConflictResolution(itemId, version,
- com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
- return true;
+
+ @Override
+ public void preResolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution) {
+ if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
+ return;
+ }
+ resolveDependantConflicts(itemId, version, conflictId, resolution);
}
- Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
- if (conflict == null) {
- throw getConflictNotExistException(itemId, version, conflictId);
+
+ @Override
+ public boolean resolveConflict(String itemId, Version version, String conflictId, ConflictResolution resolution) {
+ if (VSP_MODEL_CONFLICT_ID.equals(conflictId)) {
+ vspMergeDao
+ .updateConflictResolution(itemId, version, com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
+ return true;
+ }
+ Conflict conflict = conflictsDao.getConflict(itemId, version, conflictId);
+ if (conflict == null) {
+ throw getConflictNotExistException(itemId, version, conflictId);
+ }
+ if (conflict.getType() == VspModel) {
+ vspMergeDao
+ .updateConflictResolution(itemId, version, com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
+ conflictsDao.resolveConflict(itemId, version, conflictId,
+ new ConflictResolution(conflict.getTheirs() == null ? Resolution.YOURS : Resolution.THEIRS));
+ return true;
+ }
+ return false;
}
- if (conflict.getType() == VspModel) {
- vspMergeDao.updateConflictResolution(itemId, version,
- com.amdocs.zusammen.datatypes.item.Resolution.valueOf(resolution.getResolution().name()));
- conflictsDao.resolveConflict(itemId, version, conflictId, new ConflictResolution(
- conflict.getTheirs() == null ? Resolution.YOURS : Resolution.THEIRS));
- return true;
+ private void resolveDependantConflicts(String itemId, Version version, String conflictId, ConflictResolution resolution) {
+ ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ Set<ElementType> conflictDependantTypes = ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES.get(findConflictById(conflicts, conflictId).getType());
+ if (conflictDependantTypes == null) {
+ return;
+ }
+ findConflictsByTypes(conflicts, conflictDependantTypes)
+ .forEach(dependantConflict -> conflictsDao.resolveConflict(itemId, version, dependantConflict.getId(), resolution));
}
- return false;
- }
- private void resolveDependantConflicts(String itemId, Version version, String conflictId,
- ConflictResolution resolution) {
- ItemVersionConflict conflicts = conflictsDao.getConflict(itemId, version);
+ private ConflictInfo findConflictById(ItemVersionConflict versionConflicts, String conflictId) {
+ return versionConflicts.getElementConflicts().stream().filter(elementConflict -> conflictId.equals(elementConflict.getId())).findFirst()
+ .orElseThrow(() -> new IllegalStateException(String.format("Conflict Id %s does not exist on conflicts list", conflictId)));
+ }
- Set<ElementType> conflictDependantTypes =
- ELEMENT_TYPE_TO_CONFLICT_DEPENDANT_TYPES
- .get(findConflictById(conflicts, conflictId).getType());
+ private Collection<ConflictInfo> findConflictsByTypes(ItemVersionConflict versionConflicts, Set<ElementType> elementTypes) {
+ return versionConflicts.getElementConflicts().stream().filter(elementConflict -> elementTypes.contains(elementConflict.getType()))
+ .collect(Collectors.toList());
+ }
- if (conflictDependantTypes == null) {
- return;
+ private Conflict buildVspModelConflict(String conflictId) {
+ Conflict conflict = new Conflict(conflictId, NetworkPackage, NetworkPackage.name());
+ Map<String, String> yours = new HashMap<>();
+ yours.put("File", "Local (Me)");
+ conflict.setYours(yours);
+ Map<String, String> theirs = new HashMap<>();
+ theirs.put("File", "Last Committed");
+ conflict.setTheirs(theirs);
+ return conflict;
}
- findConflictsByTypes(conflicts, conflictDependantTypes)
- .forEach(dependantConflict ->
- conflictsDao.resolveConflict(itemId, version, dependantConflict.getId(), resolution));
- }
-
- private ConflictInfo findConflictById(ItemVersionConflict versionConflicts,
- String conflictId) {
- return versionConflicts.getElementConflicts().stream()
- .filter(elementConflict -> conflictId.equals(elementConflict.getId()))
- .findFirst()
- .orElseThrow(() -> new IllegalStateException(
- String.format("Conflict Id %s does not exist on conflicts list", conflictId)));
- }
-
- private Collection<ConflictInfo> findConflictsByTypes(ItemVersionConflict versionConflicts,
- Set<ElementType> elementTypes) {
- return versionConflicts.getElementConflicts().stream()
- .filter(elementConflict -> elementTypes.contains(elementConflict.getType()))
- .collect(Collectors.toList());
- }
-
- private Conflict buildVspModelConflict(String conflictId) {
- Conflict conflict = new Conflict(conflictId, NetworkPackage, NetworkPackage.name());
-
- Map<String, String> yours = new HashMap<>();
- yours.put("File", "Local (Me)");
- conflict.setYours(yours);
-
- Map<String, String> theirs = new HashMap<>();
- theirs.put("File", "Last Committed");
- conflict.setTheirs(theirs);
- return conflict;
- }
-
- private CoreException getConflictNotExistException(String itemId, Version version,
- String conflictId) {
- return new CoreException(new ErrorCode.ErrorCodeBuilder()
- .withCategory(ErrorCategory.APPLICATION)
- .withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
- .withMessage(
- String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId))
- .build());
- }
+ private CoreException getConflictNotExistException(String itemId, Version version, String conflictId) {
+ return new CoreException(new ErrorCode.ErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION).withId(ELEMENT_CONFLICT_NOT_EXIST_ERR_ID)
+ .withMessage(String.format(ELEMENT_CONFLICT_NOT_EXISTS_MSG, itemId, version.getId(), conflictId)).build());
+ }
}