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

identify namespaces with full attributes

parent 51577a33
Branches
No related tags found
1 merge request!22Resolve "load .AppNS and .snsd files"
......@@ -24,6 +24,7 @@ import fr.centralesupelec.edf.riseclipse.iec61850.nsd.DependsOn;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.NS;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.NsdPackage;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.PubStage;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.util.NSIdentification;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.util.NsdResourceSetImpl;
import fr.centralesupelec.edf.riseclipse.util.IRiseClipseConsole;
......@@ -909,15 +910,16 @@ public class DependsOnImpl extends NsdObjectImpl implements DependsOn {
public boolean buildExplicitLinks( IRiseClipseConsole console, boolean forceUpdate ) {
if( super.buildExplicitLinks( console, forceUpdate ) ) return true;
String messagePrefix = "[NSD links] while resolving link from DependsOn (NS id: " + getParentNS().getId() + ", line: " + getLineNumber() + "): ";
String messagePrefix = "[NSD links] while resolving link from DependsOn (NS id: " + new NSIdentification( getParentNS() ) + ", line: " + getLineNumber() + "): ";
NS ns = ( ( NsdResourceSetImpl ) eResource().getResourceSet() ).getNS( getId() );
NSIdentification identification = new NSIdentification( getId(), getVersion(), getRevision(), getRelease() );
NS ns = ( ( NsdResourceSetImpl ) eResource().getResourceSet() ).getNS( identification );
if( ns == null ) {
console.warning( messagePrefix + "NS (id: " + getId() + ") not found" );
console.warning( messagePrefix + "NS (id: " + identification + ") not found" );
}
else {
setRefersToNS( ns );
console.info( "[NSD links] NS (id: " + getId() + ") refers by DependsOn in NS (id:" + getParentNS().getId() + ") found" );
console.info( "[NSD links] NS (id: " + identification + ") refers by DependsOn in NS (id:" + new NSIdentification( getParentNS() ) + ") found" );
}
return false;
}
......
/**
* 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.nsd.util;
import java.util.Objects;
import fr.centralesupelec.edf.riseclipse.iec61850.nsd.AgNSIdentification;
public class NSIdentification {
private String id;
private Integer version;
private String revision;
private Integer release;
public NSIdentification( String id, Integer version, String revision, Integer release ) {
super();
this.id = id;
this.version = version;
this.revision = revision;
this.release = release;
}
public NSIdentification( AgNSIdentification identification ) {
super();
this.id = identification.getId();
this.version = identification.getVersion();
this.revision = identification.getRevision();
this.release = identification.getRelease();
}
@Override
public int hashCode() {
return Objects.hash( id, release, revision, version );
}
@Override
public boolean equals( Object obj ) {
if( this == obj ) return true;
if( obj == null ) return false;
if( getClass() != obj.getClass() ) return false;
NSIdentification other = ( NSIdentification ) obj;
return Objects.equals( id, other.id ) && Objects.equals( release, other.release )
&& Objects.equals( revision, other.revision ) && Objects.equals( version, other.version );
}
@Override
public String toString() {
return "NSIdentification [" + ( id != null ? "id=" + id + ", " : "" )
+ ( version != null ? "version=" + version + ", " : "" )
+ ( revision != null ? "revision=" + revision + ", " : "" )
+ ( release != null ? "release=" + release : "" ) + "]";
}
}
\ No newline at end of file
......@@ -58,8 +58,8 @@ import fr.centralesupelec.edf.riseclipse.util.AbstractRiseClipseResourceSet;
public class NsdResourceSetImpl extends AbstractRiseClipseResourceSet {
private Map< String, NS > nsdResources;
private Map< String, NSDoc > nsdocResources;
private Map< NSIdentification, NS > nsdResources;
private Map< NSIdentification, NSDoc > nsdocResources;
private NsdResourceFactoryImpl resourceFactory;
public NsdResourceSetImpl( boolean strictContent, IRiseClipseConsole console ) {
......@@ -96,22 +96,24 @@ public class NsdResourceSetImpl extends AbstractRiseClipseResourceSet {
DocumentRoot root = (DocumentRoot) resource.getContents().get( 0 );
if( root.getNS() != null ) {
NS ns = ( NS ) root.getNS();
if( nsdResources.get( ns.getId() ) != null ) {
AbstractRiseClipseConsole.getConsole().error( "There is already an NSD file with is " + ns.getId() + ", " + resource.getURI() + " is ignored" );
NSIdentification id = new NSIdentification( ns );
if( nsdResources.get( id ) != null ) {
AbstractRiseClipseConsole.getConsole().error( "There is already an NSD file with NSIdentification " + id + ", " + resource.getURI() + " is ignored" );
this.getResources().remove( resource );
return;
}
nsdResources.put( ns.getId(), ns );
nsdResources.put( id, ns );
return;
}
if( root.getNSDoc() != null ) {
NSDoc nsdoc = ( NSDoc ) root.getNSDoc();
if( nsdocResources.get( nsdoc.getId() ) != null ) {
AbstractRiseClipseConsole.getConsole().error( "There is already an NSDoc file with is " + nsdoc.getId() + ", " + resource.getURI() + " is ignored" );
NSIdentification id = new NSIdentification( nsdoc );
if( nsdocResources.get( id ) != null ) {
AbstractRiseClipseConsole.getConsole().error( "There is already an NSDoc file with NSIdentification " + id + ", " + resource.getURI() + " is ignored" );
this.getResources().remove( resource );
return;
}
nsdocResources.put( nsdoc.getId(), nsdoc );
nsdocResources.put( id, nsdoc );
return;
}
AbstractRiseClipseConsole.getConsole().error( "The file " + resource.getURI() + " is not an NSD file" );
......@@ -169,7 +171,7 @@ public class NsdResourceSetImpl extends AbstractRiseClipseResourceSet {
}
public NS getNS( String id ) {
public NS getNS( NSIdentification id ) {
return nsdResources.get( id );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment