Skip to main content
summaryrefslogtreecommitdiffstats
blob: 4dd5e3ae900247219733f81e5a0cdd98108bcbdc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2013 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.core.client.internal.config;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.osee.ats.api.IAtsConfigObject;
import org.eclipse.osee.ats.api.IAtsObject;
import org.eclipse.osee.ats.core.client.search.AtsArtifactQuery;
import org.eclipse.osee.ats.core.config.AtsConfigCache;
import org.eclipse.osee.framework.core.exception.ArtifactDoesNotExist;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.Conditions;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

/**
 * @author Donald G. Dunne
 */
public class AtsArtifactConfigCache extends AtsConfigCache {

   public List<Artifact> getArtifacts(Collection<? extends IAtsObject> atsObjects) throws OseeCoreException {
      List<String> guids = new ArrayList<String>();
      for (IAtsObject atsObject : atsObjects) {
         guids.add(atsObject.getGuid());
      }
      return AtsArtifactQuery.getArtifactListFromIds(guids);
   }

   public <A extends IAtsConfigObject> Collection<A> getConfigObjects(Collection<? extends Artifact> artifacts, Class<A> clazz) {
      List<A> objects = new ArrayList<A>();
      for (Artifact art : artifacts) {
         objects.addAll(getByTag(art.getGuid(), clazz));
      }
      return objects;
   }

   public Artifact getSoleArtifact(IAtsObject artifact) throws OseeCoreException {
      return AtsArtifactQuery.getArtifactFromId(artifact.getGuid());
   }

   public Artifact getArtifact(IAtsConfigObject atsConfigObject) throws OseeCoreException {
      Conditions.checkNotNull(atsConfigObject, "atsConfigObject");
      Artifact artifact = null;
      try {
         artifact = AtsArtifactQuery.getArtifactFromId(atsConfigObject.getGuid());
      } catch (ArtifactDoesNotExist ex) {
         // do nothing
      }
      return artifact;
   }
}

Back to the top