1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package coras.reuse;
22
23 import java.util.HashMap;
24 import java.util.Map;
25
26 import no.sintef.assetrepository.Asset;
27 import no.sintef.lock.LockException;
28 import no.sintef.lock.LockRequiredException;
29 import coras.common.AssetTypeEnum;
30 import coras.common.CorasElement;
31 import coras.common.CorasRepresentation;
32 import coras.structure.ConcernEnum;
33 import coras.structure.ViewpointEnum;
34 import coras.types.ElementTypeEnum;
35 import coras.types.SubtypeEnum;
36
37 /***
38 * @author fvr
39 *
40 * TODO To change the template for this generated type comment go to
41 * Window - Preferences - Java - Code Style - Code Templates
42 */
43 public abstract class Experience extends CorasElement {
44
45 private static final String CATEGORY = "category";
46 private static final String DOMAIN = "domain";
47
48 protected static Asset createAsset(ExperiencePackage experiencePackage,
49 ElementTypeEnum type, SubtypeEnum subtype, String name,
50 String shortDescription, String fullDescription,
51 CategoryEnum category, String domain, ConcernEnum concern,
52 ViewpointEnum[] viewpoints, CorasRepresentation[] representations)
53 throws LockException {
54 if (category == null) {
55 throw new IllegalArgumentException("Experience requires non-null category");
56 }
57 Map properties = new HashMap();
58 properties.put(CATEGORY, category.toString());
59 if (domain != null) properties.put(DOMAIN, domain);
60 return createAsset(experiencePackage, AssetTypeEnum.REUSABLE_ELEMENT,
61 type, subtype, name, shortDescription, fullDescription,
62 concern, viewpoints, properties, representations);
63 }
64
65 /***
66 * @param asset
67 */
68 protected Experience(Asset asset) {
69 super(asset);
70 }
71
72
73 public CategoryEnum getCategory() {
74 return CategoryEnum.forName(getProperty(CATEGORY));
75 }
76
77 /***
78 * @return
79 */
80 public String getDomain() {
81 return getProperty(DOMAIN);
82 }
83
84 public void setDomain(String newDomain) throws LockRequiredException {
85 setProperty(DOMAIN, newDomain);
86 }
87
88 protected static ElementTypeEnum getType(Asset asset) {
89 return CorasElement.getType(asset);
90 }
91
92 }