summaryrefslogtreecommitdiffstats
blob: 8f66293b8a4d3a18b337956da7b360461d08a428 (plain)
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
/*******************************************************************************
 * Copyright (c) 2004, 2007 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.framework.access;

import org.eclipse.osee.framework.access.internal.data.ArtifactAccessObject;
import org.eclipse.osee.framework.access.internal.data.BranchAccessObject;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

/**
 * @author Jeff C. Phillips
 */
public abstract class AccessObject {
   public abstract void removeFromCache();

   public abstract void removeFromDatabase(int subjectId) throws OseeCoreException;

   public abstract int getId();

   public static AccessObject getAccessObject(Object object) {
      if (object instanceof Artifact) {
         return ArtifactAccessObject.getArtifactAccessObject((Artifact) object);
      } else if (object instanceof IOseeBranch) {
         return BranchAccessObject.getBranchAccessObject((Branch) object);
      } else {
         return null;
      }
   }

   public static AccessObject getAccessObjectFromCache(Object object) throws OseeCoreException {
      if (object instanceof Artifact) {
         return ArtifactAccessObject.getArtifactAccessObjectFromCache((Artifact) object);
      } else if (object instanceof IOseeBranch) {
         return BranchAccessObject.getBranchAccessObjectFromCache((Branch) object);
      } else {
         return null;
      }
   }
}