Skip to content

Commit

Permalink
[2145] Function border is always in dashed and italic when the inserted
Browse files Browse the repository at this point in the history
parent is allocated too and has more than one child not allocated

Bug 2145

Change-Id: I1611fa928a96ce393c4f47f8fd3d9301b2005ad9
Signed-off-by: Ali Akar <ali.akar82@gmail.com>
  • Loading branch information
aliakar82 committed Aug 20, 2018
1 parent 1b2b8b3 commit f0ea16f
Show file tree
Hide file tree
Showing 13 changed files with 837 additions and 32 deletions.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2016 THALES GLOBAL SERVICES.
* Copyright (c) 2006, 2018 THALES GLOBAL SERVICES.
* 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
Expand Down Expand Up @@ -52,7 +52,7 @@ public class FunctionExt {
* @return
*/
public static List<AbstractFunction> getRealizedFunctions(AbstractFunction fct) {
List<AbstractFunction> result = new ArrayList<AbstractFunction>();
List<AbstractFunction> result = new ArrayList<>();
for (AbstractTrace trace : fct.getOutgoingTraces()) {
if (trace instanceof FunctionRealization) {
result.add(((FunctionRealization) trace).getAllocatedFunction());
Expand All @@ -66,7 +66,7 @@ public static List<AbstractFunction> getRealizedFunctions(AbstractFunction fct)
* @return
*/
public static List<AbstractFunction> getRealizingFunctions(AbstractFunction fct) {
List<AbstractFunction> result = new ArrayList<AbstractFunction>();
List<AbstractFunction> result = new ArrayList<>();
for (AbstractTrace trace : fct.getIncomingTraces()) {
if (trace instanceof FunctionRealization) {
result.add(((FunctionRealization) trace).getAllocatingFunction());
Expand All @@ -87,7 +87,7 @@ public static final boolean isLeaf(AbstractFunction function) {
return false;
}

return function.getSubFunctions().size() == 0;
return function.getSubFunctions().isEmpty();
}

public static boolean isControlNodeOneOutput(AbstractFunction function) {
Expand Down Expand Up @@ -131,7 +131,7 @@ public static boolean isSplitFunction(AbstractFunction function) {
*/
public static List<CapellaElement> getAllocatedFunctionalExchangeFiltered(AbstractFunctionalBlock sourceEntity,
AbstractFunctionalBlock targetEntity) {
List<CapellaElement> list = new ArrayList<CapellaElement>(1);
List<CapellaElement> list = new ArrayList<>(1);

if ((sourceEntity != null) && (targetEntity != null)) {
EList<AbstractFunction> srcAllocatedFuns = sourceEntity.getAllocatedFunctions();
Expand All @@ -141,10 +141,8 @@ public static List<CapellaElement> getAllocatedFunctionalExchangeFiltered(Abstra
EList<ActivityEdge> outgoing = abstractFunction.getOutgoing();
for (ActivityEdge activityEdge : outgoing) {
ActivityNode target = activityEdge.getTarget();
if (null != target) {
if (tarAllocatedFuns.contains(target)) {
list.add((CapellaElement) activityEdge);
}
if (null != target && tarAllocatedFuns.contains(target)) {
list.add((CapellaElement) activityEdge);
}
}
}
Expand All @@ -163,7 +161,7 @@ public static List<CapellaElement> getAllocatedFunctionalExchangeFiltered(Abstra
*/
public static List<CapellaElement> getAllocatedFunctionalExchangeFilteredWithPort(
AbstractFunctionalBlock sourceEntity, AbstractFunctionalBlock targetEntity) {
List<CapellaElement> list = new ArrayList<CapellaElement>(1);
List<CapellaElement> list = new ArrayList<>(1);

if ((sourceEntity != null) && (targetEntity != null)) {
EList<AbstractFunction> srcAllocatedFuns = sourceEntity.getAllocatedFunctions();
Expand Down Expand Up @@ -192,7 +190,7 @@ public static List<CapellaElement> getAllocatedFunctionalExchangeFilteredWithPor
* @return all outgoing exchanges
*/
public static List<FunctionalExchange> getOutGoingExchange(AbstractFunction function) {
List<FunctionalExchange> result = new BasicEList<FunctionalExchange>();
List<FunctionalExchange> result = new BasicEList<>();
EList<ActivityEdge> outgoing = function.getOutgoing();
for (ActivityEdge activityEdge : outgoing) {
result.add((FunctionalExchange) activityEdge);
Expand Down Expand Up @@ -262,7 +260,7 @@ public static List<FunctionalExchange> getAllIncomingExchanges(AbstractFunction
* @return all incoming and outgoing exchanges
*/
public static List<FunctionalExchange> getAllExchanges(AbstractFunction function) {
List<FunctionalExchange> result = new BasicEList<FunctionalExchange>();
List<FunctionalExchange> result = new BasicEList<>();
result.addAll(getAllIncomingExchanges(function));
result.addAll(getAllOutgoingExchanges(function));
return result;
Expand All @@ -276,7 +274,7 @@ public static List<FunctionalExchange> getAllExchanges(AbstractFunction function
* @return all incoming exchanges
*/
public static List<FunctionalExchange> getIncomingExchange(AbstractFunction function) {
List<FunctionalExchange> result = new BasicEList<FunctionalExchange>();
List<FunctionalExchange> result = new BasicEList<>();
List<ActivityEdge> ingoing = function.getIncoming();
for (ActivityEdge activityEdge : ingoing) {
result.add((FunctionalExchange) activityEdge);
Expand All @@ -293,7 +291,7 @@ public static List<FunctionalExchange> getIncomingExchange(AbstractFunction func
* @return all incoming and outgoing exchanges
*/
public static List<FunctionalExchange> getExchanges(AbstractFunction function) {
List<FunctionalExchange> result = new BasicEList<FunctionalExchange>();
List<FunctionalExchange> result = new BasicEList<>();
List<ActivityEdge> ingoing = function.getIncoming();
for (ActivityEdge activityEdge : ingoing) {
result.add((FunctionalExchange) activityEdge);
Expand All @@ -313,7 +311,7 @@ public static List<FunctionalExchange> getExchanges(AbstractFunction function) {
* @return the owned function ports
*/
public static List<Port> getOwnedFunctionPorts(AbstractFunction function) {
List<Port> ports = new ArrayList<Port>();
List<Port> ports = new ArrayList<>();
for (InputPin inpin : function.getInputs()) {
if (inpin instanceof Port) {
ports.add((Port) inpin);
Expand Down Expand Up @@ -395,7 +393,7 @@ public static Collection<? extends FunctionPkg> getOwnedFunctionPkgs(AbstractFun
* @return
*/
public static Collection<? extends FunctionPkg> getAllFunctionPkgs(AbstractFunction aFunction) {
List<FunctionPkg> returnedList = new ArrayList<FunctionPkg>();
List<FunctionPkg> returnedList = new ArrayList<>();
if (aFunction == null) {
return returnedList;
}
Expand All @@ -420,7 +418,7 @@ public static Collection<? extends FunctionPkg> getAllFunctionPkgs(AbstractFunct
* function
*/
public static List<AbstractFunction> getAllAbstractFunctions(AbstractFunction function) {
List<AbstractFunction> returnedList = new ArrayList<AbstractFunction>();
List<AbstractFunction> returnedList = new ArrayList<>();

if (function != null) {
returnedList.add(function);
Expand All @@ -444,7 +442,7 @@ public static List<AbstractFunction> getAllAbstractFunctions(AbstractFunction fu
* @return all function in arch that do not contain any subFunctions
*/
public static List<AbstractFunction> getAllLeafAbstractFunctions(AbstractFunction function) {
List<AbstractFunction> returnedList = new ArrayList<AbstractFunction>();
List<AbstractFunction> returnedList = new ArrayList<>();
for (AbstractFunction abstractFunction : getAllAbstractFunctions(function)) {
if (isLeaf(abstractFunction)) {
returnedList.add(abstractFunction);
Expand All @@ -461,7 +459,7 @@ public static List<AbstractFunction> getAllLeafAbstractFunctions(AbstractFunctio
* @return all function in arch that do not contain any subFunctions
*/
public static List<AbstractFunction> getAllLeafAbstractFunctions(BlockArchitecture arch) {
List<AbstractFunction> returnedList = new ArrayList<AbstractFunction>();
List<AbstractFunction> returnedList = new ArrayList<>();
for (AbstractFunction function : getAllAbstractFunctions(arch)) {
if (isLeaf(function)) {
returnedList.add(function);
Expand Down Expand Up @@ -504,7 +502,7 @@ public static AbstractFunction getRootFunction(AbstractFunction function) {
* @return
*/
public static Collection<AbstractFunction> getFirstLevelAbstractFunctions(AbstractFunction function) {
Collection<AbstractFunction> result = new ArrayList<AbstractFunction>();
Collection<AbstractFunction> result = new ArrayList<>();

result.addAll(function.getOwnedFunctions());

Expand Down Expand Up @@ -551,9 +549,9 @@ public static AbstractFunction getRelatedFunction(ActivityNode node) {
* @return the list of parent functions
*/
public static List<AbstractFunction> getParentFunctions(AbstractFunction function) {
List<AbstractFunction> returnedList = new ArrayList<AbstractFunction>();
List<AbstractFunction> returnedList = new ArrayList<>();
EObject parent = function.eContainer();
while ((parent != null) && (parent instanceof AbstractFunction)) {
while (parent instanceof AbstractFunction) {
returnedList.add((AbstractFunction) parent);
parent = parent.eContainer();
}
Expand All @@ -567,7 +565,7 @@ public static List<AbstractFunction> getParentFunctions(AbstractFunction functio
* @return
*/
public static Collection<FunctionalExchange> getAllOwnedFunctionalExchanges(AbstractFunction function) {
EList<FunctionalExchange> functionExchanges = new BasicEList<FunctionalExchange>();
EList<FunctionalExchange> functionExchanges = new BasicEList<>();

List<AbstractFunction> subFunctions = getAllAbstractFunctions(function);
for (AbstractFunction abstractFunction : subFunctions) {
Expand Down Expand Up @@ -632,7 +630,7 @@ public static boolean isActorFunction(AbstractFunction element) {
* @return boolean
*/
public static boolean isRootFunction(EObject element) {
if ((null != element) && (element instanceof AbstractFunction)) {
if (element instanceof AbstractFunction) {
AbstractFunction currentFunction = (AbstractFunction) element;
AbstractFunction rootFunction = FunctionExt.getRootFunction(currentFunction);
if ((null != rootFunction) && rootFunction.equals(currentFunction)) {
Expand Down
Expand Up @@ -4940,7 +4940,7 @@
<reusedTools xsi:type="tool:ContainerDropDescription" href="common.odesign#//@ownedViewpoints[name='Common']/@ownedRepresentations[name='Class%20Diagram%20Blank']/@defaultLayer/@toolSections.1/@ownedTools[name='D%26D%20PV%20From%20Project%20Explorer']"/>
</toolSections>
<customization>
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:not (self.isAllocatedInThisComponent(container.getComponentType()))">
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:self.isDashedFunction(container.getComponentType())">
<featureCustomizations xsi:type="description:EAttributeCustomization" appliedOn="//@ownedViewpoints[name='System%20Analysis']/@ownedRepresentations[name='System%20Architecture%20Blank']/@defaultLayer/@containerMappings[name='System%20Actors']/@subNodeMappings[name='CA%20System%20Function']/@conditionnalStyles.5/@style //@ownedViewpoints[name='System%20Analysis']/@ownedRepresentations[name='System%20Architecture%20Blank']/@defaultLayer/@containerMappings[name='System%20Actors']/@subNodeMappings[name='CA%20System%20Function']/@style" attributeName="borderLineStyle" value="dash"/>
</vsmElementCustomizations>
</customization>
Expand Down
Expand Up @@ -3772,7 +3772,7 @@
<reusedTools xsi:type="tool_1:ContainerDropDescription" href="common.odesign#//@ownedViewpoints[name='Common']/@ownedRepresentations[name='Class%20Diagram%20Blank']/@defaultLayer/@toolSections.1/@ownedTools[name='D%26D%20PV%20From%20Project%20Explorer']"/>
</toolSections>
<customization>
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:not (self.isAllocatedInThisComponent(container.getComponentType()))">
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:self.isDashedFunction(container.getComponentType())">
<featureCustomizations xsi:type="description:EAttributeCustomization" appliedOn="//@ownedViewpoints[name='Logical%20Architecture']/@ownedRepresentations[name='Logical%20Architecture%20Blank']/@defaultLayer/@containerMappings[name='LAB%20Logical%20Component']/@subNodeMappings[name='LAB%20Logical%20Function']/@conditionnalStyles.5/@style //@ownedViewpoints[name='Logical%20Architecture']/@ownedRepresentations[name='Logical%20Architecture%20Blank']/@defaultLayer/@containerMappings[name='LAB%20Logical%20Component']/@subNodeMappings[name='LAB%20Logical%20Function']/@style" attributeName="borderLineStyle" value="dash"/>
</vsmElementCustomizations>
</customization>
Expand Down
Expand Up @@ -1807,7 +1807,7 @@
<reusedTools xsi:type="tool_1:ContainerDropDescription" href="common.odesign#//@ownedViewpoints[name='Common']/@ownedRepresentations[name='Class%20Diagram%20Blank']/@defaultLayer/@toolSections.1/@ownedTools[name='D%26D%20PV%20From%20Project%20Explorer']"/>
</toolSections>
<customization>
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:not (self.isAllocatedInThisComponent(container.getComponentType()))">
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:self.isDashedFunction(container.getComponentType())">
<featureCustomizations xsi:type="description:EAttributeCustomization" appliedOn="//@ownedViewpoints[name='Operational%20Analysis']/@ownedRepresentations[name='Operational%20Entity%20Blank']/@defaultLayer/@containerMappings[name='OAB_Entity1']/@subNodeMappings[name='OAB_Activity']/@conditionnalStyles.0/@style //@ownedViewpoints[name='Operational%20Analysis']/@ownedRepresentations[name='Operational%20Entity%20Blank']/@defaultLayer/@containerMappings[name='OAB_Entity1']/@subNodeMappings[name='OAB_Activity']/@style" attributeName="borderLineStyle" value="dash"/>
</vsmElementCustomizations>
</customization>
Expand Down
Expand Up @@ -4265,7 +4265,7 @@
<reusedTools xsi:type="tool_1:ContainerDropDescription" href="common.odesign#//@ownedViewpoints[name='Common']/@ownedRepresentations[name='Class%20Diagram%20Blank']/@defaultLayer/@toolSections.1/@ownedTools[name='D%26D%20PV%20From%20Project%20Explorer']"/>
</toolSections>
<customization>
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:not (self.isAllocatedInThisComponent(container.getComponentType()))">
<vsmElementCustomizations xsi:type="description:VSMElementCustomization" predicateExpression="aql:self.isDashedFunction(container.getComponentType())">
<featureCustomizations xsi:type="description:EAttributeCustomization" appliedOn="//@ownedViewpoints[name='Physical%20Architecture']/@ownedRepresentations[name='Physical%20Architecture%20Blank']/@defaultLayer/@nodeMappings[name='PAB_PhysicalFunction']/@conditionnalStyles.5/@style //@ownedViewpoints[name='Physical%20Architecture']/@ownedRepresentations[name='Physical%20Architecture%20Blank']/@defaultLayer/@nodeMappings[name='PAB_PhysicalFunction']/@style" attributeName="borderLineStyle" value="dash"/>
</vsmElementCustomizations>
</customization>
Expand Down
Expand Up @@ -2194,6 +2194,37 @@ public boolean isAllocatedInThisComponent(AbstractFunction function, EObject con
}
return true;
}

/**
*
* Function border should be dashed only in the specified use cases :
* - ALL its leaf sub-functions are allocated to component/sub-component
* - Function is not allocated directly to the displayed component
*
* @param function
* @param container
* @return Return whether the border of a function should be dashed or not.
*/
public boolean isDashedFunction(AbstractFunction function, EObject container) {
if (AbstractFunctionExt.isLeaf(function)) {
List<Component> allocatingComponent = AbstractFunctionExt.getAllocatingComponents(function);
if (!allocatingComponent.isEmpty()) {
return allocatingComponent.get(0) != container;
}
} else {
List<AbstractFunction> allLeaves = FunctionExt.getAllLeafAbstractFunctions(function);
for (AbstractFunction leaf : allLeaves) {
List<Component> allocatingComponent = AbstractFunctionExt.getAllocatingComponents(leaf);
if (allocatingComponent.size() != 1 || allocatingComponent.get(0) != container) {
// Function is not a leaf and at least one of its leaf is not allocated to given
// Component
return false;
}
}
return true;
}
return false;
}

protected boolean isAllocatedFunctionCommon(AbstractFunction function, EObject container,
LinkedList<AbstractFunction> allocatedFunctions) {
Expand Down
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DashFunctionBug</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
<nature>org.polarsys.capella.project.nature</nature>
</natures>
</projectDescription>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata:Metadata xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:metadata="http://www.polarsys.org/kitalpha/ad/metadata/1.0.0" id="_P4fmsOYsEee0WpinHtEUew">
<viewpointReferences id="_P5YXgOYsEee0WpinHtEUew" vpId="org.polarsys.capella.core.viewpoint" version="1.3.0"/>
</metadata:Metadata>

0 comments on commit f0ea16f

Please sign in to comment.