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 dabdd557 authored by Dominique Marcadet's avatar Dominique Marcadet

Model loaders moved to new plugins

parent f6212ec6
Pipeline #7409 passed with stages
in 24 seconds
......@@ -17,7 +17,9 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ocl.xtext.oclstdlib,
fr.centralesupelec.edf.riseclipse.iec61850.scl,
fr.centralesupelec.edf.riseclipse.iec61850.scl.edit,
fr.centralesupelec.edf.riseclipse.iec61850.scl.utilities,
fr.centralesupelec.edf.riseclipse.validation.ocl,
fr.centralesupelec.edf.riseclipse.iec61850.nsd,
fr.centralesupelec.edf.riseclipse.iec61850.nsd.edit,
fr.centralesupelec.edf.riseclipse.iec61850.nsd.utilities,
org.eclipse.ocl.xtext.oclinecore
/**
* Copyright (c) 2019 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.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.Diagnostician;
//import org.eclipse.ocl.pivot.delegate.OCLDelegateDomain;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.NsdPackage;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.provider.NsdItemProviderAdapterFactory;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.util.NsdResourceFactoryImpl;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.util.NsdResourceSetImpl;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.RiseClipseModelLoader;
import fr.centralesupelec.edf.riseclipse.util.TextRiseClipseConsole;
public class NsdModelLoader extends RiseClipseModelLoader {
public NsdModelLoader( IRiseClipseConsole console ) {
super( console );
}
@Override
public void reset() {
super.reset( new NsdResourceSetImpl( true, console ) );
// Register the appropriate resource factory to handle all file
// extensions.
getResourceSet().getResourceFactoryRegistry().getExtensionToFactoryMap()
.put( Resource.Factory.Registry.DEFAULT_EXTENSION, new NsdResourceFactoryImpl() );
// Register the package to ensure it is available during loading.
getResourceSet().getPackageRegistry().put( NsdPackage.eNS_URI, NsdPackage.eINSTANCE );
}
@Override
public NsdResourceSetImpl getResourceSet() {
return ( NsdResourceSetImpl ) super.getResourceSet();
}
public Resource loadWithoutValidation( String name ) {
Object eValidator = EValidator.Registry.INSTANCE.remove( NsdPackage.eINSTANCE );
Resource resource = load( name );
if( eValidator != null ) {
EValidator.Registry.INSTANCE.put( NsdPackage.eINSTANCE, eValidator );
}
return resource;
}
public static void main( String[] args ) {
IRiseClipseConsole console = new TextRiseClipseConsole();
//console.setLevel( IRiseClipseConsole.ERROR_LEVEL );
NsdModelLoader loader = new NsdModelLoader( console );
org.eclipse.ocl.xtext.oclinecore.OCLinEcoreStandaloneSetup.doSetup();
Map< Object, Object > context = new HashMap< Object, Object >();
SubstitutionLabelProvider substitutionLabelProvider = new EValidator.SubstitutionLabelProvider() {
@Override
public String getValueLabel( EDataType eDataType, Object value ) {
return Diagnostician.INSTANCE.getValueLabel( eDataType, value );
}
@Override
public String getObjectLabel( EObject eObject ) {
NsdItemProviderAdapterFactory adapter = new NsdItemProviderAdapterFactory();
IItemLabelProvider labelProvider = ( IItemLabelProvider ) adapter.adapt( eObject,
IItemLabelProvider.class );
return labelProvider.getText( eObject );
}
@Override
public String getFeatureLabel( EStructuralFeature eStructuralFeature ) {
return Diagnostician.INSTANCE.getFeatureLabel( eStructuralFeature );
}
};
context.put( EValidator.SubstitutionLabelProvider.class, substitutionLabelProvider );
for( int i = 0; i < args.length; ++i ) {
Resource resource = loader.load( args[i] );
if( resource == null ) continue;
if( resource.getContents().size() == 0 ) continue;
Diagnostic diagnostic = Diagnostician.INSTANCE.validate( resource.getContents().get( 0 ), context );
if( diagnostic.getSeverity() == Diagnostic.ERROR || diagnostic.getSeverity() == Diagnostic.WARNING ) {
for( Iterator< Diagnostic > d = diagnostic.getChildren().iterator(); d.hasNext(); ) {
Diagnostic childDiagnostic = d.next();
switch( childDiagnostic.getSeverity() ) {
case Diagnostic.ERROR:
case Diagnostic.WARNING:
console.error( "\t" + childDiagnostic.getMessage() );
}
}
}
}
loader.getResourceSet().finalizeLoad( console );
}
}
......@@ -22,6 +22,7 @@ import org.eclipse.emf.ecore.EPackage;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.ocl.pivot.validation.ComposedEValidator;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.utilities.NsdModelLoader;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
public class NsdValidator {
......
......@@ -26,6 +26,7 @@ import java.util.Map;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.SclPackage;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.provider.SclItemProviderAdapterFactory;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.utilities.SclModelLoader;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
import fr.centralesupelec.edf.riseclipse.util.RiseClipseFatalException;
import fr.centralesupelec.edf.riseclipse.util.TextRiseClipseConsole;
......@@ -50,7 +51,7 @@ public class RiseClipseValidatorSCL {
private static OCLValidator oclValidator;
private static SclItemProviderAdapterFactory sclAdapter;
private static SCLModelLoader sclLoader;
private static SclModelLoader sclLoader;
private static NsdValidator nsdValidator;
private static boolean oclValidation = false;
private static boolean nsdValidation = false;
......@@ -168,7 +169,7 @@ public class RiseClipseValidatorSCL {
nsdValidator.prepare( validator, console );
}
sclLoader = new SCLModelLoader( console );
sclLoader = new SclModelLoader( console );
sclAdapter = new SclItemProviderAdapterFactory();
}
......
/**
* 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] );
}
}
}
......@@ -115,6 +115,11 @@
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.scl.edit</artifactId>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.centralesupelec.edf.riseclipse</groupId>
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.scl.utilities</artifactId>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.centralesupelec.edf.riseclipse</groupId>
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.nsd</artifactId>
......@@ -125,6 +130,11 @@
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.nsd.edit</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>fr.centralesupelec.edf.riseclipse</groupId>
<artifactId>fr.centralesupelec.edf.riseclipse.iec61850.nsd.utilities</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
......
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