1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package coras.riskanalysis;
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 final class DocumentResult extends RiskAnalysisResult implements IDocument {
45
46 /***
47 * @param project
48 * @param name
49 * @param description
50 * @param concern
51 * @param viewpoint
52 * @return
53 * @throws LockException
54 */
55 protected static DocumentResult create(RiskAnalysisProject project,
56 String name, String shortDescription, String fullDescription,
57 ConcernEnum concern, ViewpointEnum viewpoint, DocumentRepresentation content)
58 throws LockException {
59 CorasRepresentation[] representations = content != null ? new CorasRepresentation[] { content } : new CorasRepresentation[0];
60 Asset asset = createAsset(project, ElementTypeEnum.DOCUMENT, null,
61 name, shortDescription, fullDescription, concern, viewpoint,
62 representations);
63 return new DocumentResult(asset);
64 }
65
66 /***
67 * @param assetVersion
68 */
69 protected DocumentResult(Asset asset) {
70 super(asset);
71 }
72
73
74
75
76 public DocumentRepresentation getDocumentContent() {
77 return (DocumentRepresentation) getRepresentation(RepresentationTypeEnum.DOCUMENT);
78 }
79
80
81
82
83 public void setDocumentContent(File documentFile) throws IOException, LockRequiredException {
84 DocumentRepresentation newDocument = RepresentationFactory.createDocument(documentFile);
85 setDocumentContent(newDocument);
86 }
87
88
89
90
91 public void setDocumentContent(DocumentRepresentation newDocument) throws LockRequiredException {
92 DocumentRepresentation oldDocument = getDocumentContent();
93 removeRepresentation(oldDocument);
94 addRepresentation(newDocument);
95 }
96
97 }