Skip to content

Commit 99b2f62

Browse files
committed
ST6RI-178 Fixed non-standard library upload and some typos
1 parent 7af297f commit 99b2f62

5 files changed

Lines changed: 34 additions & 27 deletions

File tree

org.omg.sysml/src/org/omg/sysml/util/repository/APIModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public void merge(APIModel other) {
118118
* @param delta changes to apply.
119119
*/
120120
public void merge(APIModelDelta delta) {
121-
throw new UnsupportedOperationException("Not impelemnted");
121+
throw new UnsupportedOperationException("Not implemented");
122122
}
123123

124124
/**

org.omg.sysml/src/org/omg/sysml/util/repository/APIModelDelta.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public boolean isEmpty() {
9494
*
9595
* @return list model changes acceptable by the API server
9696
*/
97-
public List<DataVersion> toTrasferableDelta() {
97+
public List<DataVersion> toTransferableDelta() {
9898
List<DataVersion> delta = new LinkedList<>();
9999

100100
for (Element addition: getAdditions()) {
@@ -126,7 +126,7 @@ public List<DataVersion> toTrasferableDelta() {
126126
* @return JSON string
127127
*/
128128
public String toJson(Gson gson) {
129-
return gson.toJson(toTrasferableDelta());
129+
return gson.toJson(toTransferableDelta());
130130
}
131131

132132
/**
@@ -136,34 +136,34 @@ public String toJson(Gson gson) {
136136
* @return JSON string
137137
*/
138138
public JsonElement toJsonTree(Gson gson) {
139-
return gson.toJsonTree(toTrasferableDelta());
139+
return gson.toJsonTree(toTransferableDelta());
140140
}
141141

142142
/**
143143
* Creates an {@link APIModelDelta} between two {@link APIModel}s
144144
*
145-
* @param thisModel model to compare with baseline
145+
* @param current model to compare with baseline
146146
* @param baseline model to use as a baseline
147147
*
148148
* @return {@link APIModelDelta} of the two models
149149
*/
150-
public static APIModelDelta create(APIModel thisModel, APIModel baseline) {
151-
if (thisModel == null) thisModel = APIModel.createEmpty();
150+
public static APIModelDelta create(APIModel current, APIModel baseline) {
151+
if (current == null) current = APIModel.createEmpty();
152152
if (baseline == null) baseline = APIModel.createEmpty();
153153

154154
Set<Element> additions = new HashSet<>();
155155
Set<UUID> deletions = new HashSet<>();
156156
Map<UUID, ChangedElement> changes = new HashMap<>();
157157

158-
Map<UUID, Element> elementsFromThis = thisModel.getModelElements();
158+
Map<UUID, Element> currentElements = current.getModelElements();
159159

160-
for (UUID id: elementsFromThis.keySet()) {
160+
for (UUID id: currentElements.keySet()) {
161161
Element baselineElement = baseline.getElement(id);
162162
if (baselineElement == null) {
163-
additions.add(thisModel.getElement(id));
163+
additions.add(current.getElement(id));
164164
} else {
165-
Element thisElement = thisModel.getElement(id);
166-
ChangedElement change = createElementDelta(thisElement, baselineElement);
165+
Element currentElement = current.getElement(id);
166+
ChangedElement change = createElementDelta(currentElement, baselineElement);
167167
if (change != null) {
168168
changes.put(id, change);
169169
}
@@ -173,7 +173,7 @@ public static APIModelDelta create(APIModel thisModel, APIModel baseline) {
173173
Map<UUID, Element> elementsFromBaseline = baseline.getModelElements();
174174

175175
for (UUID id: elementsFromBaseline.keySet()) {
176-
Element element = thisModel.getElement(id);
176+
Element element = current.getElement(id);
177177
if (element == null) {
178178
deletions.add(id);
179179
}
@@ -185,31 +185,31 @@ public static APIModelDelta create(APIModel thisModel, APIModel baseline) {
185185
/**
186186
* Creates a {@link Data} object which contains changed fields and their new values
187187
*
188-
* @param thisElement element to compare with baseline
188+
* @param currentElement element to compare with baseline
189189
* @param baselineElement element to use as a baseline
190190
* @return changed fields and their new values wrapped in a {@link Data} object.
191191
*/
192-
public static ChangedElement createElementDelta(Element thisElement, Element baselineElement) {
192+
public static ChangedElement createElementDelta(Element currentElement, Element baselineElement) {
193193
ChangedElement change = null;
194-
Set<String> fieldsInThis = thisElement.keySet();
194+
Set<String> fieldsInThis = currentElement.keySet();
195195
for (String field: fieldsInThis) {
196-
Object thisValue = thisElement.get(field);
196+
Object currentValue = currentElement.get(field);
197197
Object baselineValue = baselineElement.get(field);
198-
if (!Objects.equal(thisValue, baselineValue)) {
198+
if (!Objects.equal(currentValue, baselineValue)) {
199199
if (change == null) change = new ChangedElement(baselineElement);
200-
change.add(field, thisValue);
200+
change.add(field, currentValue);
201201
}
202202
}
203203

204204
return change;
205205
}
206206

207207
private static class ChangedElement {
208-
private Element originalElement;
208+
private Element baselineElement;
209209
private Map<String, Object> changes = new HashMap<>();
210210

211-
public ChangedElement(Element originalElement) {
212-
this.originalElement = originalElement;
211+
public ChangedElement(Element baselineElement) {
212+
this.baselineElement = baselineElement;
213213
}
214214

215215
public void add(String field, Object thisValue) {
@@ -218,7 +218,7 @@ public void add(String field, Object thisValue) {
218218

219219
public Data toData() {
220220
Data data = new Data();
221-
data.putAll(originalElement);
221+
data.putAll(baselineElement);
222222
data.putAll(changes);
223223
return data;
224224
}

org.omg.sysml/src/org/omg/sysml/util/repository/ProjectRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,8 @@ public Commit commitChanges(UUID projectId, UUID branchId, UUID previousCommitId
350350
}
351351

352352
protected ProjectApi getProjectApi() {
353-
return projectApi; }
353+
return projectApi;
354+
}
354355

355356
protected ElementApi getElementApi() {
356357
return elementApi;

org.omg.sysml/src/org/omg/sysml/util/repository/Revision.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public Revision pushChanges(APIModelDelta changes) {
127127
return this;
128128
}
129129
APIModelDelta localChanges = getLocalChanges();
130-
return pushChanges(localChanges.toTrasferableDelta());
130+
return pushChanges(localChanges.toTransferableDelta());
131131
}
132132

133133
/**

org.omg.sysml/src/org/omg/sysml/util/traversal/facade/impl/JsonElementProcessingFacade.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.eclipse.emf.ecore.EReference;
3636
import org.eclipse.emf.ecore.EStructuralFeature;
3737
import org.omg.sysml.lang.sysml.Element;
38+
import org.omg.sysml.lang.sysml.LibraryPackage;
3839
import org.omg.sysml.util.ElementUtil;
3940
import org.omg.sysml.util.repository.APIModel;
4041
import org.omg.sysml.util.repository.APIModelDelta;
@@ -182,7 +183,7 @@ protected org.omg.sysml.model.Element createApiModelElement(Element element) {
182183
//unstable library membership UUIDs in the EMFModelRefresher.
183184
if ((this.isIncludeDerived() || !feature.isDerived() || "importedElement".equals(feature.getName())) &&
184185
// Skip implementation-specific features.
185-
!(/*"Feature".equals(className) && */"isNonunique".equals(featureName) ||
186+
!("isNonunique".equals(featureName) ||
186187
"OperatorExpression".equals(className) && "operand".equals(featureName) ||
187188
apiElement.containsKey(featureName))) {
188189
Object value = element.eGet(feature);
@@ -266,11 +267,16 @@ public void postProcess(Element element) {
266267
org.omg.sysml.model.Element apiModelElement = this.createApiModelElement(element);
267268
UUID id = UUID.fromString(apiModelElement.get("@id").toString());
268269

269-
if (element.eContainer() == null || element.isLibraryElement()) {
270+
if (element.eContainer() == null || isStandardLibraryElement(element)) {
270271
this.getLocalModel().addModelRoot(id, apiModelElement);
271272
}
272273
this.getLocalModel().addModelElement(id, apiModelElement);;
273274
}
275+
276+
boolean isStandardLibraryElement(Element element) {
277+
return element.eResource().getContents().stream().filter(LibraryPackage.class::isInstance)
278+
.map(LibraryPackage.class::cast).anyMatch(LibraryPackage::isStandard);
279+
}
274280

275281
protected APIModel getLocalModel() {
276282
return localModel;

0 commit comments

Comments
 (0)