use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class IndexedModelTest method testMergeInterfaceOperationsFromNull.
@Test
public void testMergeInterfaceOperationsFromNull() {
// FROM's operation is null
Map<String, Interface> from = Maps.newHashMap();
Interface i1 = new Interface();
from.put("i1", i1);
Map<String, Interface> to = Maps.newHashMap();
Interface i2 = new Interface();
Map<String, Operation> ios2 = Maps.newHashMap();
Operation o2 = new Operation();
ios2.put("o1", o2);
i2.setOperations(ios2);
to.put("i1", i2);
Map<String, Interface> merged = IndexedModelUtils.mergeInterfaces(from, to);
assertEquals(1, merged.size());
assertSame(merged.get("i1").getOperations().get("o1"), o2);
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class IndexedModelTest method testMergeInterfacesBasic.
@Test
public void testMergeInterfacesBasic() {
Map<String, Interface> from = Maps.newHashMap();
Interface i1 = new Interface();
from.put("i1", i1);
Map<String, Interface> to = Maps.newHashMap();
Interface i2 = new Interface();
to.put("i2", i2);
Map<String, Interface> merged = IndexedModelUtils.mergeInterfaces(from, to);
assertEquals(2, merged.size());
assertSame(merged.get("i1"), i1);
assertSame(merged.get("i2"), i2);
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processOperationsInputsForOperationOutputs.
/**
* Check operations input of every operations of all interfaces of a IPaaSTemplate for get_operation_output usage, and register in the related operation
* the output name
*
* @param paaSTemplate
* @param paaSNodeTemplates
*/
private <V extends AbstractInstantiableToscaType> void processOperationsInputsForOperationOutputs(final IPaaSTemplate<V> paaSTemplate, final Map<String, PaaSNodeTemplate> paaSNodeTemplates) {
Map<String, Interface> interfaces = ((AbstractInstantiableToscaType) paaSTemplate.getIndexedToscaElement()).getInterfaces();
if (interfaces != null) {
for (Interface interfass : interfaces.values()) {
for (Operation operation : interfass.getOperations().values()) {
Map<String, IValue> inputsParams = operation.getInputParameters();
if (inputsParams != null) {
for (Entry<String, IValue> input : inputsParams.entrySet()) {
String name = input.getKey();
IValue value = input.getValue();
processIValueForOperationOutput(name, value, paaSTemplate, paaSNodeTemplates, false);
}
}
}
}
}
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method registerOperationOutput.
@SuppressWarnings({ "unchecked", "rawtypes" })
private <V extends AbstractInstantiableToscaType> void registerOperationOutput(final List<? extends IPaaSTemplate> paaSTemplates, final String interfaceName, final String operationName, final String output, final String formatedAttributeName) {
for (IPaaSTemplate<V> paaSTemplate : paaSTemplates) {
if (paaSTemplate.getInterfaces() != null) {
Interface interfass = MapUtils.getObject(paaSTemplate.getInterfaces(), (interfaceName));
if (interfass != null && interfass.getOperations().containsKey(operationName)) {
OperationOutput toAdd = new OperationOutput(output);
if (StringUtils.isNotBlank(formatedAttributeName)) {
toAdd.getRelatedAttributes().add(formatedAttributeName);
}
interfass.getOperations().get(operationName).addOutput(toAdd);
}
}
}
}
use of org.alien4cloud.tosca.model.definitions.Interface in project alien4cloud by alien4cloud.
the class RuntimeController method validateCommand.
private void validateCommand(OperationExecRequest operationRequest, Topology topology) throws ConstraintFunctionalException {
NodeTemplate nodeTemplate = TopologyUtils.getNodeTemplate(topology.getId(), operationRequest.getNodeTemplateName(), TopologyUtils.getNodeTemplates(topology));
NodeType indexedNodeType = toscaTypeSearchService.getRequiredElementInDependencies(NodeType.class, nodeTemplate.getType(), topology.getDependencies());
Map<String, Interface> interfaces = IndexedModelUtils.mergeInterfaces(indexedNodeType.getInterfaces(), nodeTemplate.getInterfaces());
if (interfaces == null || interfaces.get(operationRequest.getInterfaceName()) == null) {
throw new NotFoundException("Interface [" + operationRequest.getInterfaceName() + "] not found in the node template [" + operationRequest.getNodeTemplateName() + "] related to [" + indexedNodeType.getId() + "]");
}
Interface interfass = interfaces.get(operationRequest.getInterfaceName());
validateOperation(interfass, operationRequest, topology.getDependencies());
}
Aggregations