Skip to content

Commit 10fa86f

Browse files
committed
ST6RI-178 Updated Jupyter %publish not to upload derived fields by
default - derived elements are no longer uploaded by default by Jupyter %publish - with the exception of importedElements which is needed to support a workaround to addresses unstable membership UUIDs - added flag '-d' to the command to still enable derived fields as an option
1 parent 2cc5447 commit 10fa86f

4 files changed

Lines changed: 13 additions & 8 deletions

File tree

org.omg.sysml.interactive/src/org/omg/sysml/interactive/SysMLInteractive.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ public String show(String name) {
407407
show(name, Collections.emptyList(), Collections.emptyList()));
408408
}
409409

410-
public String publish(String elementName, String projectName, String branchName, List<String> help) {
410+
public String publish(String elementName, String projectName, String branchName, boolean includeDerievd, List<String> help) {
411411
this.counter++;
412412
if (Strings.isNullOrEmpty(elementName)) {
413413
return help.isEmpty()? "": SysMLInteractiveHelp.getPublishHelp();
@@ -421,7 +421,7 @@ public String publish(String elementName, String projectName, String branchName,
421421
} else {
422422
String remoteProjectName = projectName == null? element.getDeclaredName() + " " + new Date() : projectName;
423423

424-
ApiElementProcessingFacade processingFacade = this.getApiElementProcessingFacade(remoteProjectName, branchName);
424+
ApiElementProcessingFacade processingFacade = this.getApiElementProcessingFacade(remoteProjectName, branchName, includeDerievd);
425425
processingFacade.getTraversal().visit(element);
426426
processingFacade.commit(element);
427427
System.out.println();
@@ -434,8 +434,8 @@ public String publish(String elementName, String projectName, String branchName,
434434

435435
protected String publish(String name) {
436436
return "-h".equals(name)?
437-
publish(null, null, null, Collections.singletonList("true")):
438-
publish(name, null, null, Collections.emptyList());
437+
publish(null, null, null, false, Collections.singletonList("true")):
438+
publish(name, null, null, false, Collections.emptyList());
439439
}
440440

441441
public String loadByName(String projectName, String branchName, List<String> help) {
@@ -552,10 +552,10 @@ public String listPublications(List<String> help) {
552552
.collect(Collectors.joining("\n"));
553553
}
554554

555-
protected ApiElementProcessingFacade getApiElementProcessingFacade(String modelName, String branchName) {
555+
protected ApiElementProcessingFacade getApiElementProcessingFacade(String modelName, String branchName, boolean includeDerived) {
556556
System.out.println("API base path: " + this.apiBasePath);
557557
ApiElementProcessingFacade processingFacade = new ApiElementProcessingFacade(modelName, branchName, this.apiBasePath);
558-
processingFacade.setIsIncludeDerived(true);
558+
processingFacade.setIsIncludeDerived(includeDerived);
559559
processingFacade.setTraversal(new Traversal(processingFacade));
560560
return processingFacade;
561561
}

org.omg.sysml.interactive/src/org/omg/sysml/interactive/SysMLInteractiveHelp.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public class SysMLInteractiveHelp {
8282
"Usage: %publish <NAME>\n\n"
8383
+ "Publish the model elements rooted in <NAME> to the repository. <NAME> must be fully qualified.\n"
8484
+ "Use the --project parameter to specify a project to create or update. If not specified, a new project is created with the name of the model element and a timestamp.\n"
85+
+ "Use the -d flag to include derived properties\n"
8586
+ "(Experimental) Use --branch to specify the target branch name. If not specified, the default branch is selected.\n";
8687

8788
private static final String VIZ_HELP_STRING =

org.omg.sysml.jupyter.kernel/src/main/java/org/omg/sysml/jupyter/kernel/magic/Publish.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class Publish {
3131
.optional("element")
3232
.keyword("project")
3333
.keyword("branch")
34+
.flag("derived", 'd', "false")
3435
.flag("help", 'h', "true")
3536
.build();
3637

@@ -43,7 +44,8 @@ public static String publish(List<String> args) {
4344
String element = elements.isEmpty()? null:elements.get(0);
4445
String project = projects.isEmpty()? null:projects.get(0);
4546
String branch = branches.isEmpty()? null:branches.get(0);
47+
boolean includeDerived = !vals.get("derived").isEmpty();
4648
List<String> help = vals.get("help");
47-
return ISysML.getKernelInstance().getInteractive().publish(element, project, branch, help);
49+
return ISysML.getKernelInstance().getInteractive().publish(element, project, branch, includeDerived, help);
4850
}
4951
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ protected org.omg.sysml.model.Element createApiModelElement(Element element) {
178178
for (EStructuralFeature feature: eClass.getEAllStructuralFeatures()) {
179179
String className = eClass.getName();
180180
String featureName = feature.getName();
181-
if ((this.isIncludeDerived() || !feature.isDerived()) &&
181+
//always add the importedElement derived field. This field is used for a workaround that addresses
182+
//unstable library membership UUIDs in the EMFModelRefresher.
183+
if ((this.isIncludeDerived() || !feature.isDerived() || "importedElement".equals(feature.getName())) &&
182184
// Skip implementation-specific features.
183185
!(/*"Feature".equals(className) && */"isNonunique".equals(featureName) ||
184186
"OperatorExpression".equals(className) && "operand".equals(featureName) ||

0 commit comments

Comments
 (0)