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 d4845b40 authored by Pedro Donini Linan's avatar Pedro Donini Linan

Small test to get to know nsdResource(NSD) and eObject(SCL).

parent c4050bf4
......@@ -21,6 +21,7 @@ package fr.centralesupelec.edf.riseclipse.iec61850.scl.validator;
import java.util.Map;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
......@@ -28,9 +29,18 @@ import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.Resource;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.DocumentRoot;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TBasicType;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TBasicTypes;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TCDC;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TDataAttribute;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TDataObject;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TFunctionalConstraint;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TFunctionalConstraints;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TLNClass;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TLNClasses;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.TNS;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.impl.DAIImpl;
import fr.centralesupelec.edf.riseclipse.iec61850.scl.impl.DAImpl;
import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseConsole;
public class NSDEObjectValidator implements EValidator {
......@@ -51,6 +61,8 @@ public class NSDEObjectValidator implements EValidator {
TFunctionalConstraint fc0 = fcs.getFunctionalConstraint().get( 0 );
AbstractRiseClipseConsole.getConsole().info( " FunctionalConstraint.titleID: " + fc0.getTitleID() );
}
}
@Override
......@@ -61,8 +73,27 @@ public class NSDEObjectValidator implements EValidator {
@Override
public boolean validate( EClass eClass, EObject eObject, DiagnosticChain diagnostics,
Map< Object, Object > context ) {
AbstractRiseClipseConsole.getConsole().info( "NSDEObjectValidator.validate( EClass ): " + eClass.getName() );
AbstractRiseClipseConsole.getConsole().info( "NSDEObjectValidator.validate( EClass ): " + eClass.getName());
// TODO: use nsdResource to validate eObject
DocumentRoot root = (DocumentRoot) nsdResource.getContents().get( 0 );
TNS tns = (TNS) root.getNS();
if(eClass.getName().equals("DA")) {
log("\nClass " + eClass.getName());
EList<TBasicType> tda = tns.getBasicTypes().getBasicType();
DAImpl da = (DAImpl) eObject;
log("DA " + da.getBType());
for(int i = 0; i < tda.size(); i++) {
if(da.getBType().equals(tda.get(i).getName())) {
log("tda " + tda.get(i).getName());
log("true");
return true;
}
}
}
return true;
}
......@@ -70,8 +101,15 @@ public class NSDEObjectValidator implements EValidator {
public boolean validate( EDataType eDataType, Object value, DiagnosticChain diagnostics,
Map< Object, Object > context ) {
AbstractRiseClipseConsole.getConsole().info( "NSDEObjectValidator.validate( EDataType ): " + eDataType.getName() );
// TODO: use nsdResource to validate value
return true;
}
public void log(String message) {
AbstractRiseClipseConsole.getConsole().info(message);
}
}
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