Skip to content

Commit

Permalink
[2044] Information view messages logged during a model validation
Browse files Browse the repository at this point in the history
Bug 2044

Change-Id: Ie01976a79b305528b318c983e4edbe3765b11ee5
Signed-off-by: Ali Akar <ali.akar82@gmail.com>
  • Loading branch information
aliakar82 authored and pdulth committed May 15, 2018
1 parent 01d3cc3 commit 6c5ffe8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
Expand Up @@ -21,11 +21,13 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.sirius.business.api.session.Session;
import org.eclipse.sirius.business.api.session.SessionManager;
import org.polarsys.capella.core.transition.common.constants.IOptionsConstants;
import org.polarsys.capella.core.transition.common.constants.ITransitionConstants;
import org.polarsys.capella.core.transition.common.constants.ITransitionSteps;
import org.polarsys.capella.core.transition.common.constants.Messages;
import org.polarsys.capella.core.transition.common.handlers.log.LogHelper;
import org.polarsys.kitalpha.cadence.core.api.parameter.ActivityParameters;
import org.polarsys.kitalpha.cadence.core.api.parameter.GenericParameter;
import org.polarsys.kitalpha.transposer.api.ITransposerWorkflow;
import org.polarsys.kitalpha.transposer.rules.handler.rules.api.IContext;

Expand Down Expand Up @@ -73,7 +75,10 @@ public IStatus _run(ActivityParameters activityParams) {
}
}

LogHelper.getInstance().info("Operation has been successful.", Messages.Activity_Transition);
GenericParameter<?> parameter = activityParams.getParameter(IOptionsConstants.IS_DRY_RUN);
if(parameter == null || !Boolean.valueOf(parameter.getValue().toString())){
LogHelper.getInstance().info("Operation has been successful.", Messages.Activity_Transition);
}

return Status.OK_STATUS;
}
Expand Down
@@ -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 All @@ -24,5 +24,7 @@ public class IOptionsConstants {
public static final String OPTIONS_LOG = "log.enabled";

public static final Boolean OPTIONS_LOG__DEFAULT = Boolean.TRUE;

public static final String IS_DRY_RUN = "isDryRun";

}
Expand Up @@ -44,12 +44,12 @@ public Rule_FunctionPort(EClass sourceType_p, EClass targetType_p) {
protected abstract Collection<FunctionalExchange> getRelatedFunctionalExchanges(FunctionPort p);

@Override
protected Collection<InterfaceInfo> transformToInterfaceInfo(EObject element, ITransfo transfo_p) {
protected Collection<InterfaceInfo> transformToInterfaceInfo(EObject element, ITransfo transfo) {

Collection<InterfaceInfo> result = new ArrayList<InterfaceInfo>();

for (FunctionalExchange fe : getRelatedFunctionalExchanges((FunctionPort)element)){
if (isExternal(fe)){
if (isExternal(fe, transfo)){
return Collections.emptyList();
}
}
Expand All @@ -74,7 +74,7 @@ protected Collection<InterfaceInfo> transformToInterfaceInfo(EObject element, IT

abstract ProviderRequirerRole getRole();

private boolean isExternal(FunctionalExchange exchange){
private boolean isExternal(FunctionalExchange exchange, ITransfo transfo){

AbstractFunction sourceF = FunctionalExchangeExt.getSourceFunction(exchange);
AbstractFunction targetF = FunctionalExchangeExt.getTargetFunction(exchange);
Expand All @@ -84,21 +84,24 @@ private boolean isExternal(FunctionalExchange exchange){
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)));
if(!transfo.isDryRun()){
// 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)));
if(!transfo.isDryRun()){
// The target function has not been allocated to any component
String message = targetF.getName() + " 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;
}

}
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2017 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 @@ -150,8 +150,11 @@ private static Map<FunctionalExchange, InterfaceInfo> getInfoMap(ITransfo transf
return map;
}

private void logMultipleInfosFound(EObject exchange){
_logger.error(new EmbeddedMessage("Skipping generation for functional exchange " + EObjectLabelProviderHelper.getText(exchange) + " which has inconsistent or multiple port/ce allocations", _logger.getName(), exchange));
private void logMultipleInfosFound(EObject exchange, ITransfo transfo){
// Do not log error in the Information view when this rule is executed during a model validation
if(!transfo.isDryRun()){
_logger.error(new EmbeddedMessage("Skipping generation for functional exchange " + EObjectLabelProviderHelper.getText(exchange) + " which has inconsistent or multiple port/ce allocations", _logger.getName(), exchange));
}
}

private void logNoInfosFound(EObject element) {
Expand Down Expand Up @@ -191,7 +194,7 @@ InterfaceInfo getInterfaceInfo(FunctionalExchange element, ITransfo transfo){
} else if (infos.isEmpty()){
logNoInfosFound(element); // internal exchange
} else {
logMultipleInfosFound(element); // exchange is somehow allocated multiple times/and/or/inconsistently
logMultipleInfosFound(element, transfo); // exchange is somehow allocated multiple times/and/or/inconsistently
}
infomap.put((FunctionalExchange) element, result);
}
Expand Down
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2017 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 @@ -27,6 +27,8 @@
import org.polarsys.capella.common.re.CatalogElementKind;
import org.polarsys.capella.common.re.RePackage;
import org.polarsys.capella.common.re.launcher.Rpl2RecConformanceCheckLauncher;
import org.polarsys.capella.core.transition.common.constants.IOptionsConstants;
import org.polarsys.kitalpha.cadence.core.api.parameter.GenericParameter;

public class DCON_02_Rpl2RecConformanceConstraint extends AbstractModelConstraint {

Expand Down Expand Up @@ -56,6 +58,7 @@ private IStatus validateRPL(IValidationContext ctx, CatalogElement rpl) {
Collection<Object> selection = new ArrayList<Object>();
selection.add(rpl);
Rpl2RecConformanceCheckLauncher launcher = new Rpl2RecConformanceCheckLauncher();
launcher.addSharedParameter(new GenericParameter<Boolean>(IOptionsConstants.IS_DRY_RUN, true, "This is a flag to indicate a dry run"));
launcher.run(selection, false, new NullProgressMonitor());
if (!launcher.isConform()) {
// When the target is a REC, we need to set the RPL as target of the created failure status to be able to use it
Expand Down

0 comments on commit 6c5ffe8

Please sign in to comment.