Skip to content

Commit

Permalink
[1964] BasicIndexOutOfBoundsException while generating interfaces from
Browse files Browse the repository at this point in the history
allocated functions

Bug: 1964
Change-Id: I6b7a13ef758ccb8af6e6345ecf26b820b52d2291
Signed-off-by: cong-bang.do <docongbang1993@gmail.com>
  • Loading branch information
bang-dc committed Feb 19, 2018
1 parent a370116 commit 33db0c0
Showing 1 changed file with 21 additions and 1 deletion.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017 THALES GLOBAL SERVICES.
* Copyright (c) 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 All @@ -11,11 +11,16 @@
package org.polarsys.capella.core.projection.interfaces.generateInterfaces;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;

import org.apache.log4j.Logger;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.polarsys.capella.common.tools.report.EmbeddedMessage;
import org.polarsys.capella.common.tools.report.config.registry.ReportManagerRegistry;
import org.polarsys.capella.common.tools.report.util.IReportManagerDefaultComponents;
import org.polarsys.capella.core.data.fa.AbstractFunction;
import org.polarsys.capella.core.data.fa.ComponentPort;
import org.polarsys.capella.core.data.fa.FunctionPort;
Expand All @@ -28,6 +33,8 @@ abstract class Rule_FunctionPort extends InterfaceGenerationRule {

private final static ProviderRequirerTracing tracing = new ProviderRequirerTracing();

private static final Logger logger = ReportManagerRegistry.getInstance().subscribe(IReportManagerDefaultComponents.REFINEMENT);

public Rule_FunctionPort(EClass sourceType_p, EClass targetType_p) {
super(sourceType_p, targetType_p);
}
Expand Down Expand Up @@ -68,14 +75,27 @@ protected Collection<InterfaceInfo> transformToInterfaceInfo(EObject element, IT
abstract ProviderRequirerRole getRole();

private boolean isExternal(FunctionalExchange exchange){

AbstractFunction sourceF = FunctionalExchangeExt.getSourceFunction(exchange);
AbstractFunction targetF = FunctionalExchangeExt.getTargetFunction(exchange);

boolean result = true;
result &= sourceF != null;
result &= targetF != null;
result &= sourceF.getAllocationBlocks().size() > 0;
if (!result) {
// The source function has not been allocated to any component
String message = sourceF.getName() + " has not been allocated to any component";
logger.warn(new EmbeddedMessage(message, logger.getName(), Arrays.asList(sourceF)));
return true;
}
result &= targetF.getAllocationBlocks().size() > 0;
if (!result) {
String message = targetF.getName() + " has not been allocated to any component";
// The target function has not been allocated to any component
logger.warn(new EmbeddedMessage(message, logger.getName(), Arrays.asList(targetF)));
return true;
}
result &= sourceF.getAllocationBlocks().get(0) != targetF.getAllocationBlocks().get(0);

return result;
Expand Down

0 comments on commit 33db0c0

Please sign in to comment.