Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 743355a7 authored by Dominique Marcadet's avatar Dominique Marcadet

enable back OCL validation

parent 3aa5358b
......@@ -20,31 +20,32 @@ package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator;
import java.util.ArrayList;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.provider.NsdItemProviderAdapterFactory;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.SclPackage;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.provider.SclItemProviderAdapterFactory;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.RiseClipseFatalException;
import fr.centralesupelec.edf.riseclipse.util.TextRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.validation.ocl.OCLValidator;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.validation.ComposedEValidator;
public class RiseClipseValidatorSCL {
//private static OCLValidator oclValidator;
private static OCLValidator oclValidator;
private static SclItemProviderAdapterFactory sclAdapter;
private static SCLModelLoader sclLoader;
private static NsdValidator nsdValidator;
//private static boolean oclValidation = false;
private static boolean oclValidation = false;
private static boolean nsdValidation = false;
private static NsdItemProviderAdapterFactory nsdAdapter;
public static void usage( IRiseClipseConsole console ) {
console.setLevel( IRiseClipseConsole.INFO_LEVEL );
console.info(
"java -jar RiseClipseValidatorSCL.jar [--verbose] [--make-explicit-links] [<oclFile> | <nsdFile> | <sclFile>]*" );
console.info( /*"Files ending with \".ocl\" are considered OCL files, "
+*/ "files ending with \\\".nsd\\\" are considered NSD files, "
console.info( "Files ending with \".ocl\" are considered OCL files, "
+ "files ending with \\\".nsd\\\" are considered NSD files, "
+ "all others are considered SCL files" );
System.exit( -1 );
}
......@@ -78,15 +79,15 @@ public class RiseClipseValidatorSCL {
}
}
//ArrayList< String > oclFiles = new ArrayList<>();
ArrayList< String > oclFiles = new ArrayList<>();
ArrayList< String > nsdFiles = new ArrayList<>();
ArrayList< String > sclFiles = new ArrayList<>();
for( int i = posFiles; i < args.length; ++i ) {
/*if( args[i].endsWith( ".ocl" )) {
if( args[i].endsWith( ".ocl" ) ) {
oclFiles.add( args[i] );
oclValidation = true;
}
else*/ if( args[i].endsWith( ".nsd" ) ) {
else if( args[i].endsWith( ".nsd" ) ) {
nsdFiles.add( args[i] );
nsdValidation = true;
}
......@@ -95,7 +96,7 @@ public class RiseClipseValidatorSCL {
}
}
prepare( console, /*oclFiles,*/ nsdFiles );
prepare( console, oclFiles, nsdFiles );
for( int i = 0; i < sclFiles.size(); ++i ) {
run( console, make_explicit_links, sclFiles.get( i ) );
}
......@@ -123,35 +124,40 @@ public class RiseClipseValidatorSCL {
}
public static void prepare( IRiseClipseConsole console,
/*ArrayList< String > oclFiles,*/ ArrayList< String > nsdFiles ) {
@NonNull
ComposedEValidator validator = ComposedEValidator.install( SclPackage.eINSTANCE );
ArrayList< String > oclFiles, ArrayList< String > nsdFiles ) {
SclPackage sclPg = SclPackage.eINSTANCE;
if( sclPg == null ) {
throw new RiseClipseFatalException( "SCL package not found", null );
}
ComposedEValidator validator = ComposedEValidator.install( sclPg );
if( oclValidation ) {
// TODO: change OCLValidator constructor to take same arguments as NsdValidator ?
//oclValidator = new OCLValidator( validator, true );
oclValidator = new OCLValidator( sclPg, true );
/*if( oclValidation ) {
oclValidator = new OCLValidator( validator, true );
for( int i = 0; i < oclFiles.size(); ++i ) {
oclValidator.addOCLDocument( oclFiles.get( i ), console );
}
}*/
}
if( nsdValidation ) {
nsdValidator = new NsdValidator( validator, console );
for( int i = 0; i < nsdFiles.size(); ++i ) {
nsdValidator.addNsdDocument( nsdFiles.get( i ), console );
}
//nsdAdapter = new NsdItemProviderAdapterFactory();
}
sclLoader = new SCLModelLoader( console );
sclAdapter = new SclItemProviderAdapterFactory();
/*for(EValidator v: validator.getChildren()) {
if(v.getClass() == NsdEObjectValidator.class) {
NsdEObjectValidator nsdValidator = (NsdEObjectValidator) v;
nsdValidator.initializeValidationData();
}
}*/
for( EValidator v : validator.getChildren() ) {
if( v.getClass() == NsdEObjectValidator.class ) {
NsdEObjectValidator nsdValidator = ( NsdEObjectValidator ) v;
nsdValidator.initializeValidationData();
}
}
}
public static void run( IRiseClipseConsole console, boolean make_explicit_links, String sclFile ) {
......@@ -162,10 +168,10 @@ public class RiseClipseValidatorSCL {
sclLoader.finalizeLoad();
}
if( resource != null ) {
/*if( oclValidation ) {
if( oclValidation ) {
console.info( "Validating file: " + sclFile + " with OCL" );
oclValidator.validate( resource, sclAdapter, console );
}*/
}
if( nsdValidation ) {
console.info( "Validating file: " + sclFile + " with NSD" );
nsdValidator.validate( resource, sclAdapter, console );
......
Markdown is supported
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