blob: 5cdc76d1be6a8e341556be04a26f34f35b071897 (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*******************************************************************************
* 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.disposition.rest.internal;
import org.eclipse.osee.disposition.model.DispoConfig;
import org.eclipse.osee.disposition.model.DispoSet;
import org.eclipse.osee.disposition.rest.DispoConstants;
import org.eclipse.osee.framework.jdk.core.type.BaseIdentity;
import org.eclipse.osee.framework.jdk.core.type.Named;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.json.JSONArray;
import org.json.JSONException;
import com.google.gson.Gson;
/**
* @author Angel Avila
*/
public class DispoSetArtifact extends BaseIdentity<String> implements DispoSet, Comparable<Named> {
private final ArtifactReadable artifact;
public DispoSetArtifact(ArtifactReadable artifact) {
super(artifact.getGuid());
this.artifact = artifact;
}
@Override
public String getName() {
return artifact.getName();
}
@Override
public String getImportPath() {
return artifact.getSoleAttributeAsString(DispoConstants.ImportPath);
}
@Override
public JSONArray getNotesList() {
String notesJson = artifact.getSoleAttributeAsString(DispoConstants.DispoNotesJson, "[]");
try {
return new JSONArray(notesJson);
} catch (JSONException ex) {
throw new OseeCoreException("Could not parse Notes Json", ex);
}
}
@Override
public int compareTo(Named other) {
if (other != null && other.getName() != null && getName() != null) {
return getName().compareTo(other.getName());
}
return -1;
}
@Override
public String toString() {
return getName();
}
@Override
public String getImportState() {
return artifact.getSoleAttributeAsString(DispoConstants.ImportState, "NOT_SET");
}
@Override
public DispoConfig getDispoConfig() {
Gson gson = new Gson();
return gson.fromJson(artifact.getSoleAttributeAsString(DispoConstants.DispoConfig, "{}"), DispoConfig.class);
}
}
|