Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid W. Miller2017-08-22 12:24:04 -0400
committerRyan Brooks2017-08-22 14:07:52 -0400
commita444e5f62d82ba48f7d470cda6572214a3d1e074 (patch)
treed1cce80780c914cfabb729e03f248b7d5bf690ce
parent75065e0d2428ffe9261590a06da6b048302caacc (diff)
downloadorg.eclipse.osee-a444e5f62d82ba48f7d470cda6572214a3d1e074.tar.gz
org.eclipse.osee-a444e5f62d82ba48f7d470cda6572214a3d1e074.tar.xz
org.eclipse.osee-a444e5f62d82ba48f7d470cda6572214a3d1e074.zip
bug[ats_TW1708]: Fix Attribute Adapter service by adding default
-rw-r--r--plugins/org.eclipse.osee.ats/OSGI-INF/ats.branch.art.ref.attr.adaptor.xml7
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsBranchArtifactReferenceAttributeAdapter.java53
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/artifact.reference.adapter.xml7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/ArtifactAttributeAdapter.java14
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/AttributeAdapterServiceImpl.java8
5 files changed, 10 insertions, 79 deletions
diff --git a/plugins/org.eclipse.osee.ats/OSGI-INF/ats.branch.art.ref.attr.adaptor.xml b/plugins/org.eclipse.osee.ats/OSGI-INF/ats.branch.art.ref.attr.adaptor.xml
deleted file mode 100644
index 65c6cc1ef0..0000000000
--- a/plugins/org.eclipse.osee.ats/OSGI-INF/ats.branch.art.ref.attr.adaptor.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0">
- <implementation class="org.eclipse.osee.ats.config.AtsBranchArtifactReferenceAttributeAdapter"/>
- <service>
- <provide interface="org.eclipse.osee.framework.skynet.core.attribute.AttributeAdapter"/>
- </service>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsBranchArtifactReferenceAttributeAdapter.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsBranchArtifactReferenceAttributeAdapter.java
deleted file mode 100644
index a14c020ca7..0000000000
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/config/AtsBranchArtifactReferenceAttributeAdapter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.ats.config;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
-import org.eclipse.osee.ats.internal.AtsClientService;
-import org.eclipse.osee.framework.core.data.AttributeTypeId;
-import org.eclipse.osee.framework.jdk.core.type.Id;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
-import org.eclipse.osee.framework.skynet.core.artifact.Attribute;
-import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
-import org.eclipse.osee.framework.skynet.core.attribute.AttributeAdapter;
-
-/**
- * Artifact Referenced Attributes that point to current Ats Branch
- *
- * @author Donald G. Dunne
- */
-public class AtsBranchArtifactReferenceAttributeAdapter implements AttributeAdapter<Artifact> {
-
- private static final List<AttributeTypeId> PROGRAM_UUID_LIST =
- Arrays.asList(AtsAttributeTypes.ProgramUuid, AtsAttributeTypes.TeamDefinitionReference,
- AtsAttributeTypes.WorkPackageProgram, AtsAttributeTypes.ActionableItemReference);
-
- @Override
- public Collection<AttributeTypeId> getSupportedTypes() {
- return PROGRAM_UUID_LIST;
- }
-
- @Override
- public Artifact adapt(Attribute<?> attribute, Id identity) throws OseeCoreException {
- Artifact resultProgramArt = null;
-
- int uuid = identity.getId() <= 0 ? 0 : identity.getId().intValue();
- if (uuid > 0) {
- resultProgramArt = ArtifactQuery.getArtifactFromId(uuid, AtsClientService.get().getAtsBranch());
- }
- return resultProgramArt;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/artifact.reference.adapter.xml b/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/artifact.reference.adapter.xml
deleted file mode 100644
index 5aad7a2750..0000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/OSGI-INF/artifact.reference.adapter.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.osee.framework.skynet.core.attribute.service.ArtifactAttributeAdapter">
- <implementation class="org.eclipse.osee.framework.skynet.core.attribute.service.ArtifactAttributeAdapter"/>
- <service>
- <provide interface="org.eclipse.osee.framework.skynet.core.attribute.AttributeAdapter"/>
- </service>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/ArtifactAttributeAdapter.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/ArtifactAttributeAdapter.java
index 995bc6a944..ea3df927c2 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/ArtifactAttributeAdapter.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/ArtifactAttributeAdapter.java
@@ -11,9 +11,7 @@
package org.eclipse.osee.framework.skynet.core.attribute.service;
import java.util.Collection;
-import java.util.Collections;
import org.eclipse.osee.framework.core.data.AttributeTypeId;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.jdk.core.type.Id;
@@ -29,17 +27,13 @@ import org.eclipse.osee.framework.skynet.core.attribute.AttributeAdapter;
public class ArtifactAttributeAdapter implements AttributeAdapter<Artifact> {
@Override
- public Artifact adapt(Attribute<?> attribute, Id identity) throws OseeCoreException {
- Long uuid = identity.getId();
- if (uuid <= 0L) {
- return null;
- }
- return ArtifactQuery.getArtifactFromId(new Long(uuid).intValue(), CoreBranches.COMMON,
- DeletionFlag.EXCLUDE_DELETED);
+ public Artifact adapt(Attribute<?> attribute, Id id) throws OseeCoreException {
+ return ArtifactQuery.getArtifactFromId(id.getId(), CoreBranches.COMMON, DeletionFlag.EXCLUDE_DELETED);
}
@Override
public Collection<AttributeTypeId> getSupportedTypes() {
- return Collections.singleton(CoreAttributeTypes.ArtifactReference);
+ throw new UnsupportedOperationException(
+ "Should never be called because the default adpater does not need to be registered.");
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/AttributeAdapterServiceImpl.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/AttributeAdapterServiceImpl.java
index 20c6985a16..970c933497 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/AttributeAdapterServiceImpl.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/attribute/service/AttributeAdapterServiceImpl.java
@@ -35,11 +35,11 @@ public class AttributeAdapterServiceImpl implements AttributeAdapterService {
private final List<ServiceReference<AttributeAdapter<?>>> pending;
private volatile boolean ready = false;
private Thread thread;
+ private final ArtifactAttributeAdapter defaultAdapter = new ArtifactAttributeAdapter();
public AttributeAdapterServiceImpl() {
registered = new ConcurrentHashMap<>();
pending = new CopyOnWriteArrayList<>();
-
adapterByType = new ConcurrentHashMap<>();
}
@@ -129,7 +129,11 @@ public class AttributeAdapterServiceImpl implements AttributeAdapterService {
@SuppressWarnings("unchecked")
public <T> AttributeAdapter<T> getAdapter(AttributeTypeId type) {
- return (AttributeAdapter<T>) adapterByType.get(type);
+ AttributeAdapter<T> adapter = (AttributeAdapter<T>) adapterByType.get(type);
+ if (adapter == null) {
+ adapter = (AttributeAdapter<T>) defaultAdapter;
+ }
+ return adapter;
}
} \ No newline at end of file

Back to the top