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.io.File;
24 import java.io.IOException;
25
26 import no.sintef.assetrepository.Asset;
27 import no.sintef.lock.LockException;
28 import no.sintef.lock.LockRequiredException;
29 import coras.common.CorasRepresentation;
30 import coras.representations.DocumentRepresentation;
31 import coras.representations.RepresentationFactory;
32 import coras.representations.RepresentationTypeEnum;
33 import coras.structure.ConcernEnum;
34 import coras.structure.ViewpointEnum;
35 import coras.types.ElementTypeEnum;
36 import coras.types.IDocument;
37
38 /***
39 * @author fvr
40 *
41 * TODO To change the template for this generated type comment go to
42 * Window - Preferences - Java - Code Style - Code Templates
43 */
44 public class DocumentExperience extends Experience implements IDocument {
45
46 /***
47 * @param experiencePackage
48 * @param name
49 * @param description
50 * @param concern
51 * @param viewpoint
52 * @return
53 * @throws LockException
54 */
55 protected static DocumentExperience create(
56 ExperiencePackage experiencePackage, String name,
57 String shortDescription, String fullDescription,
58 CategoryEnum category, String domain, ConcernEnum concern,
59 ViewpointEnum[] viewpoints, DocumentRepresentation content)
60 throws LockException {
61 CorasRepresentation[] representations = content != null ? new CorasRepresentation[] { content } : new CorasRepresentation[0];
62 Asset asset = createAsset(experiencePackage, ElementTypeEnum.DOCUMENT,
63 null, name, shortDescription, fullDescription, category,
64 domain, concern, viewpoints, representations);
65 return new DocumentExperience(asset);
66 }
67
68 /***
69 * @param asset
70 */
71 protected DocumentExperience(Asset asset) {
72 super(asset);
73 }
74
75
76
77
78 public DocumentRepresentation getDocumentContent() {
79 return (DocumentRepresentation) getRepresentation(RepresentationTypeEnum.DOCUMENT);
80 }
81
82
83
84
85 public void setDocumentContent(File documentFile) throws IOException, LockRequiredException {
86 DocumentRepresentation newDocument = RepresentationFactory.createDocument(documentFile);
87 setDocumentContent(newDocument);
88 }
89
90
91
92
93 public void setDocumentContent(DocumentRepresentation newDocument) throws LockRequiredException {
94 DocumentRepresentation oldDocument = getDocumentContent();
95 removeRepresentation(oldDocument);
96 addRepresentation(newDocument);
97 }
98
99 }