Skip to content
Snippets Groups Projects
Commit d1b55f68 authored by Dominique Marcadet's avatar Dominique Marcadet
Browse files

Merge branch '1-use-riseclipseoclvalidator_scl2003-as-the-starting-point' into 'master'

Resolve "Use RiseClipseOCLValidator_SCL2003 as the starting point"

Closes #1

See merge request RiseClipseGroup/RiseClipseValidator_SCL2003!1
parents fccdc7e8 057e9e00
No related branches found
No related tags found
1 merge request!1Resolve "Use RiseClipseOCLValidator_SCL2003 as the starting point"
Showing
with 322 additions and 1 deletion
# RiseClipseSCLValidator # RiseClipseValidator_SCL2003
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fr.centralesupelec.edf.riseclipse.iec61850.scl.validator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: RiseClipse IEC61850 SCL Tools
Bundle-Vendor: CentraleSupélec & EDF
Bundle-SymbolicName: fr.centralesupelec.edf.riseclipse.iec61850.scl.validator
Bundle-Version: 1.0.0.qualifier
Export-Package: fr.centralesupelec.edf.riseclipse.iec61850.scl.validator
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore,
org.eclipse.emf.edit,
org.eclipse.emf.common,
org.eclipse.emf.ecore.xmi,
fr.centralesupelec.edf.riseclipse.main,
org.eclipse.ocl.pivot,
org.eclipse.ocl.xtext.completeocl,
org.eclipse.ocl.xtext.oclstdlib,
fr.centralesupelec.edf.riseclipse.iec61850.scl,
fr.centralesupelec.edf.riseclipse.iec61850.scl.edit,
fr.centralesupelec.edf.riseclipse.validation.ocl,
fr.centralesupelec.edf.riseclipse.iec61850.nsd
# Copyright (c) 2018 CentraleSuplec & EDF.
# 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
# http://www.eclipse.org/legal/epl-v10.html
#
# This file is part of the RiseClipse tool
#
# Contributors:
# Computer Science Department, CentraleSuplec
# EDF R&D
# Contacts:
# dominique.marcadet@centralesupelec.fr
# aurelie.dehouck-neveu@edf.fr
# Web site:
# http://wdi.supelec.fr/software/RiseClipse/
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
# Copyright (c) 2018 CentraleSuplec & EDF.
# 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
# http://www.eclipse.org/legal/epl-v10.html
#
# This file is part of the RiseClipse tool
#
# Contributors:
# Computer Science Department, CentraleSuplec
# EDF R&D
# Contacts:
# dominique.marcadet@centralesupelec.fr
# aurelie.dehouck-neveu@edf.fr
# Web site:
# http://wdi.supelec.fr/software/RiseClipse/
pluginName = RiseClipse IEC 61850 SCL Tools
providerName = CentraleSuplec & EDF
/**
* Copyright (c) 2018 CentraleSupélec & EDF.
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator;
import java.io.File;
import java.util.ArrayList;
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.TextRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.validation.ocl.OCLValidator;
//import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
public class RiseClipseValidatorSCL {
private static OCLValidator ocl;
private static SclItemProviderAdapterFactory adapter;
private static SCLModelLoader loader;
public static void usage( IRiseClipseConsole console ) {
console.setLevel( IRiseClipseConsole.INFO_LEVEL );
console.info( "java -jar RiseClipseValidatorSCL.jar [--verbose] [--make-explicit-links] [<oclFile> | <sclFile>]*" );
console.info( "Files ending with \".ocl\" are considered OCL files, all others are considered SCL files" );
System.exit( -1 );
}
public static void main( String[] args ) {
final IRiseClipseConsole console = new TextRiseClipseConsole();
console.setLevel( IRiseClipseConsole.INFO_LEVEL );
displayLegal( console );
console.setLevel( IRiseClipseConsole.WARNING_LEVEL );
if( args.length == 0 ) usage( console );
boolean make_explicit_links = false;
int posFiles = 0;
for( int i = 0; i < args.length; ++i ) {
if( args[i].startsWith( "--" )) {
posFiles = i + 1;
if( "--verbose".equals( args[i] )) {
console.setLevel( IRiseClipseConsole.INFO_LEVEL );
}
else if( "--make-explicit-links".equals( args[i] )) {
make_explicit_links = true;
}
else {
console.error( "Unrecognized option " + args[i] );
usage( console );
}
}
}
ArrayList< File > oclFiles = new ArrayList<>();
ArrayList< String > sclFiles = new ArrayList<>();
for( int i = posFiles; i < args.length; ++i ) {
if( args[i].endsWith( ".ocl" )) {
oclFiles.add( new File( args[i] ));
}
else {
sclFiles.add( args[i] );
}
}
prepare( console, oclFiles );
for( int i = 0; i < sclFiles.size(); ++i ) {
run( console, make_explicit_links, sclFiles.get( i ));
}
}
public static void displayLegal( IRiseClipseConsole console ) {
console.info( "Copyright (c) 2018 CentraleSupélec & EDF." );
console.info( "All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0" );
console.info( "which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html" );
console.info( "" );
console.info( "This file is part of the RiseClipse tool." );
console.info( "Contributors:" );
console.info( " Computer Science Department, CentraleSupélec" );
console.info( " EDF R&D" );
console.info( "Contacts:" );
console.info( " dominique.marcadet@centralesupelec.fr" );
console.info( " aurelie.dehouck-neveu@edf.fr" );
console.info( "Web site:" );
console.info( " http://wdi.supelec.fr/software/RiseClipse/" );
console.info( "" );
console.info( "RiseClipseSCLValidator version: 1.0.1 (6 June 2018)" );
console.info( "" );
}
public static void prepare( IRiseClipseConsole console, ArrayList< File > oclFiles ) {
SclPackage sclPg = SclPackage.eINSTANCE;
ocl = new OCLValidator( sclPg, true );
for( int i = 0; i < oclFiles.size(); ++i ) {
console.info( "Loading ocl: " + oclFiles.get( i ));
// workaround for bug 486872
// File file = new File( oclFiles.get( i ));
// URI uri = file.isFile() ? URI.createFileURI( file.getAbsolutePath() ) : URI.createURI( oclFiles.get( i ));
// oclFiles.add( uri );
// ocl.addOCLDocument( uri, console );
ocl.addOCLDocument( oclFiles.get( i ), console );
}
loader = new SCLModelLoader( console );
adapter = new SclItemProviderAdapterFactory();
}
public static void run( IRiseClipseConsole console, boolean make_explicit_links, String sclFile ) {
loader.reset();
Resource resource = loader.loadWithoutValidation( sclFile );
if( make_explicit_links ) {
console.info( "Making explicit links for file: " + sclFile );
loader.finalizeLoad();
}
if( resource != null ) {
console.info( "Validating file: " + sclFile );
ocl.validate( resource, adapter, console );
}
}
}
/**
* Copyright (c) 2018 CentraleSupélec & EDF.
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* This file is part of the RiseClipse tool
*
* Contributors:
* Computer Science Department, CentraleSupélec
* EDF R&D
* Contacts:
* dominique.marcadet@centralesupelec.fr
* aurelie.dehouck-neveu@edf.fr
* Web site:
* http://wdi.supelec.fr/software/RiseClipse/
*/
package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.SclPackage;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.util.SclResourceFactoryImpl;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.RiseClipseModelLoader;
import fr.centralesupelec.edf.riseclipse.util.TextRiseClipseConsole;
public class SCLModelLoader extends RiseClipseModelLoader {
public SCLModelLoader( IRiseClipseConsole console ) {
super( console );
}
@Override
public void reset() {
super.reset();
// Register the appropriate resource factory to handle all file
// extensions.
getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap()
.put( Resource.Factory.Registry.DEFAULT_EXTENSION, new SclResourceFactoryImpl() );
// Register the package to ensure it is available during loading.
getResourceSet().getPackageRegistry().put( SclPackage.eNS_URI, SclPackage.eINSTANCE );
}
public Resource loadWithoutValidation( String name ) {
Object eValidator = EValidator.Registry.INSTANCE.remove( SclPackage.eINSTANCE );
Resource resource = load( name );
if( eValidator != null ) {
EValidator.Registry.INSTANCE.put( SclPackage.eINSTANCE, eValidator );
}
return resource;
}
public static void main( String[] args ) {
IRiseClipseConsole console = new TextRiseClipseConsole();
SCLModelLoader loader = new SCLModelLoader( console );
for( int i = 0; i < args.length; ++i ) {
@SuppressWarnings( "unused" )
Resource resource = loader.load( args[i] );
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment