Commit ea62f1fb authored by Simon Barner's avatar Simon Barner
Browse files

Fix build. TaskAllocationUtils to be deleted later.

refs 3067
parent 395932e9
TaskAllocationUtils.java a656e4c8082afce931f3e10b2a2afe4c887c893f YELLOW
TaskArchitectureUtils.java 2b56a1561ae0ebb7e5f4b737f7a527242879c8a6 YELLOW
TaskAllocationUtils.java da58103cbd66cc6d5c47837aa9df7ee6e5d8aac0 RED
TaskArchitectureUtils.java 664e491a33133a8a7d4e7bd53cb26fb786d88b87 YELLOW
TaskModelElementFactory.java 9630bfe039d21b3bdeb29c101d17d9a37876ebaf YELLOW
/*-------------------------------------------------------------------------+
| Copyright 2017 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.task.util;
import java.util.Collection;
import java.util.Collections;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.task.model.Task;
import org.fortiss.af3.task.model.TaskAllocation;
import org.fortiss.af3.task.model.TaskArchitecture;
/**
* Utility methods for the handling of {@link TaskAllocation}s.
*
* @author diewald
*/
@Deprecated
public class TaskAllocationUtils {
/**
* Returns the first found {@link TaskAllocation} of the given {@link Task}, or {@code null} if
* none is found.
*
* @param taskArchitecture
* contains the {@link TaskAllocation}s.
* @param task
* {@link Task} to search for.
* @return {@link TaskAllocation} allocating the given {@link Task}.
*/
@Deprecated
public static TaskAllocation getAllocationOf(TaskArchitecture taskArchitecture, Task task) {
for(TaskAllocation taskAllocation : taskArchitecture.getTaskAllocations()) {
if(taskAllocation.getTask() == task) {
return taskAllocation;
}
}
return null;
}
/**
* Returns the Collection of {@link Component}s allocated to a task from the first found
* {@link TaskAllocation} of the given {@link Task}, or
* an empty collection if none is found.
*
* @param taskArchitecture
* contains the {@link TaskAllocation}s.
* @param task
* {@link Task} to search for.
* @return Collection of {@link Component}s allocated to the given {@link Task}.
*/
@Deprecated
public static Collection<Component> getAllocatedComponentsTo(TaskArchitecture taskArchitecture,
Task task) {
for(TaskAllocation taskAllocation : taskArchitecture.getTaskAllocations()) {
if(taskAllocation.getTask() == task) {
return taskAllocation.getComponents();
}
}
return Collections.emptyList();
}
}
......@@ -23,6 +23,7 @@ import static org.fortiss.af3.task.util.TaskModelElementFactory.createSignal;
import static org.fortiss.af3.task.util.TaskModelElementFactory.createTask;
import static org.fortiss.af3.task.util.TaskModelElementFactory.createTaskArchitecture;
import static org.fortiss.af3.task.util.TaskModelElementFactory.createTaskSamplingInputPort;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickFirstInstanceOf;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.computeFullyQualifiedName;
import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParentElement;
import static org.fortiss.tooling.kernel.utils.UniqueIDUtils.fixMissingIDs;
......@@ -33,6 +34,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.eclipse.emf.common.util.EList;
import org.fortiss.af3.allocation.model.AllocationTableCollection;
import org.fortiss.af3.component.model.Channel;
import org.fortiss.af3.component.model.Component;
import org.fortiss.af3.component.model.ComponentArchitecture;
......@@ -50,6 +52,7 @@ import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationEntry;
import org.fortiss.af3.task.model.allocation.ComponentToTaskAllocationTable;
import org.fortiss.af3.task.model.allocation.InputPortToTaskInputPortAllocationEntry;
import org.fortiss.af3.task.model.allocation.OutputPortToTaskOutputPortAllocationEntry;
import org.fortiss.af3.task.model.allocation.TaskToExecutionUnitAllocationTable;
/**
* Utility methods for handling {@link TaskArchitecture}s and its sub elements.
......@@ -193,4 +196,24 @@ public class TaskArchitectureUtils {
// There is exactly one task
return tasks.get(0);
}
/**
* Returns a {@link ComponentToTaskAllocationTable} from the given
* {@link AllocationTableCollection}.
*/
public static ComponentToTaskAllocationTable getComponentToTaskAllocationTable(
AllocationTableCollection allocationTableCollection) {
return pickFirstInstanceOf(ComponentToTaskAllocationTable.class,
allocationTableCollection.getContainedElements());
}
/**
* Returns a {@link TaskToExecutionUnitAllocationTable} from the given
* {@link AllocationTableCollection}.
*/
public static TaskToExecutionUnitAllocationTable getTaskToExecutionUnitAllocationTable(
AllocationTableCollection allocationTableCollection) {
return pickFirstInstanceOf(TaskToExecutionUnitAllocationTable.class,
allocationTableCollection.getContainedElements());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment