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

apply changes of AtLeastOne to other affected presence conditions

parent c673e648
No related branches found
No related tags found
1 merge request!24Resolve "the base LNClass is handled differently according to presence conditions"
...@@ -142,6 +142,10 @@ public class DataObjectPresenceConditionValidator { ...@@ -142,6 +142,10 @@ public class DataObjectPresenceConditionValidator {
// and duplicate it in each sub-LNClass for adding specific elements // and duplicate it in each sub-LNClass for adding specific elements
if( base == null ) { if( base == null ) {
atLeastOne = new HashMap<>(); atLeastOne = new HashMap<>();
atMostOne = new HashSet<>();
allOrNonePerGroup = new HashMap<>();
allOnlyOneGroup = new HashMap<>();
allAtLeastOneGroup = new HashMap<>();
} }
else { else {
atLeastOne = ( HashMap< Integer, HashSet< String > > ) base.atLeastOne.clone(); atLeastOne = ( HashMap< Integer, HashSet< String > > ) base.atLeastOne.clone();
...@@ -152,6 +156,31 @@ public class DataObjectPresenceConditionValidator { ...@@ -152,6 +156,31 @@ public class DataObjectPresenceConditionValidator {
} }
} }
atMostOne = ( HashSet< String > ) base.atMostOne.clone();
for( String name : atMostOne ) {
presentDO.put( name, null );
}
allOrNonePerGroup = ( HashMap< Integer, HashSet< String > > ) base.allOrNonePerGroup.clone();
for( Integer group : allOrNonePerGroup.keySet() ) {
for( String name : allOrNonePerGroup.get( group )) {
presentDO.put( name, null );
}
}
allOnlyOneGroup = ( HashMap< Integer, HashSet< String > > ) base.allOnlyOneGroup.clone();
for( Integer group : allOnlyOneGroup.keySet() ) {
for( String name : allOnlyOneGroup.get( group )) {
presentDO.put( name, null );
}
}
allAtLeastOneGroup = ( HashMap< Integer, HashSet< String > > ) base.allAtLeastOneGroup.clone();
for( Integer group : allAtLeastOneGroup.keySet() ) {
for( String name : allAtLeastOneGroup.get( group )) {
presentDO.put( name, null );
}
}
} }
anyLNClass anyLNClass
...@@ -235,13 +264,13 @@ public class DataObjectPresenceConditionValidator { ...@@ -235,13 +264,13 @@ public class DataObjectPresenceConditionValidator {
} }
case "AtMostOne" : case "AtMostOne" :
// At most one of marked elements shall be present // At most one of marked elements shall be present
if( atMostOne == null ) atMostOne = new HashSet<>(); //if( atMostOne == null ) atMostOne = new HashSet<>();
atMostOne.add( name ); atMostOne.add( name );
break; break;
case "AllOrNonePerGroup" : case "AllOrNonePerGroup" :
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All or none of the elements of a group n shall be present // All or none of the elements of a group n shall be present
if( allOrNonePerGroup == null ) allOrNonePerGroup = new HashMap<>(); //if( allOrNonePerGroup == null ) allOrNonePerGroup = new HashMap<>();
try { try {
Integer arg = Integer.valueOf( presCondArgs ); Integer arg = Integer.valueOf( presCondArgs );
if( arg <= 0 ) { if( arg <= 0 ) {
...@@ -261,7 +290,7 @@ public class DataObjectPresenceConditionValidator { ...@@ -261,7 +290,7 @@ public class DataObjectPresenceConditionValidator {
case "AllOnlyOneGroup" : case "AllOnlyOneGroup" :
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All elements of only one group n shall be present // All elements of only one group n shall be present
if( allOnlyOneGroup == null ) allOnlyOneGroup = new HashMap<>(); //if( allOnlyOneGroup == null ) allOnlyOneGroup = new HashMap<>();
try { try {
Integer arg = Integer.valueOf( presCondArgs ); Integer arg = Integer.valueOf( presCondArgs );
if( arg <= 0 ) { if( arg <= 0 ) {
...@@ -281,7 +310,7 @@ public class DataObjectPresenceConditionValidator { ...@@ -281,7 +310,7 @@ public class DataObjectPresenceConditionValidator {
case "AllAtLeastOneGroup" : case "AllAtLeastOneGroup" :
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All elements of at least one group n shall be present // All elements of at least one group n shall be present
if( allAtLeastOneGroup == null ) allAtLeastOneGroup = new HashMap<>(); //if( allAtLeastOneGroup == null ) allAtLeastOneGroup = new HashMap<>();
try { try {
Integer arg = Integer.valueOf( presCondArgs ); Integer arg = Integer.valueOf( presCondArgs );
if( arg <= 0 ) { if( arg <= 0 ) {
...@@ -860,6 +889,7 @@ public class DataObjectPresenceConditionValidator { ...@@ -860,6 +889,7 @@ public class DataObjectPresenceConditionValidator {
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// At least one of marked elements of a group n shall be present // At least one of marked elements of a group n shall be present
// Usage in standard NSD files (version 2007B): DataObject and SubDataObject and DataAttribute and SubDataAttribute // Usage in standard NSD files (version 2007B): DataObject and SubDataObject and DataAttribute and SubDataAttribute
//if( atLeastOne != null ) {
if( ! asSuperclass ) { if( ! asSuperclass ) {
AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AtLeastOne\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AtLeastOne\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() );
for( Entry< Integer, HashSet< String > > e1 : atLeastOne.entrySet() ) { for( Entry< Integer, HashSet< String > > e1 : atLeastOne.entrySet() ) {
...@@ -885,7 +915,8 @@ public class DataObjectPresenceConditionValidator { ...@@ -885,7 +915,8 @@ public class DataObjectPresenceConditionValidator {
// presCond: "AtMostOne" : // presCond: "AtMostOne" :
// At most one of marked elements shall be present // At most one of marked elements shall be present
// Usage in standard NSD files (version 2007B): DataObject // Usage in standard NSD files (version 2007B): DataObject
if( atMostOne != null ) { //if( atMostOne != null ) {
if( ! asSuperclass ) {
AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AtMostOne\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AtMostOne\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() );
int count = 0; int count = 0;
for( String s : atMostOne ) { for( String s : atMostOne ) {
...@@ -908,7 +939,8 @@ public class DataObjectPresenceConditionValidator { ...@@ -908,7 +939,8 @@ public class DataObjectPresenceConditionValidator {
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All or none of the elements of a group n shall be present // All or none of the elements of a group n shall be present
// Usage in standard NSD files (version 2007B): DataAttribute // Usage in standard NSD files (version 2007B): DataAttribute
if( allOrNonePerGroup != null ) { //if( allOrNonePerGroup != null ) {
if( ! asSuperclass ) {
AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllOrNonePerGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllOrNonePerGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() );
for( Entry< Integer, HashSet< String > > e1 : allOrNonePerGroup.entrySet() ) { for( Entry< Integer, HashSet< String > > e1 : allOrNonePerGroup.entrySet() ) {
int groupCount = 0; int groupCount = 0;
...@@ -933,7 +965,8 @@ public class DataObjectPresenceConditionValidator { ...@@ -933,7 +965,8 @@ public class DataObjectPresenceConditionValidator {
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All elements of only one group n shall be present // All elements of only one group n shall be present
// Usage in standard NSD files (version 2007B): DataObject and SubDataAttribute // Usage in standard NSD files (version 2007B): DataObject and SubDataAttribute
if( allOnlyOneGroup != null ) { //if( allOnlyOneGroup != null ) {
if(( ! asSuperclass ) && ( allOnlyOneGroup.size() != 0 )) { // groupNumber == 0 not an error if empty
AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllOnlyOneGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllOnlyOneGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() );
int groupNumber = 0; int groupNumber = 0;
for( Entry< Integer, HashSet< String > > e1 : allOnlyOneGroup.entrySet() ) { for( Entry< Integer, HashSet< String > > e1 : allOnlyOneGroup.entrySet() ) {
...@@ -982,7 +1015,8 @@ public class DataObjectPresenceConditionValidator { ...@@ -982,7 +1015,8 @@ public class DataObjectPresenceConditionValidator {
// Parameter n: group number (> 0). // Parameter n: group number (> 0).
// All elements of at least one group n shall be present // All elements of at least one group n shall be present
// Usage in standard NSD files (version 2007B): DataAttribute // Usage in standard NSD files (version 2007B): DataAttribute
if( allAtLeastOneGroup != null ) { //if( allAtLeastOneGroup != null ) {
if(( ! asSuperclass ) && ( allAtLeastOneGroup.size() != 0 )) { // groupNumber == 0 not an error if empty
AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllAtLeastOneGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() ); AbstractRiseClipseConsole.getConsole().verbose( "[NSD validation] validation of presence condition \"AllAtLeastOneGroup\" on LNodeType (id=" + lNodeType.getId() + ") at line " + lNodeType.getLineNumber() );
int groupNumber = 0; int groupNumber = 0;
for( Entry< Integer, HashSet< String > > e1 : allAtLeastOneGroup.entrySet() ) { for( Entry< Integer, HashSet< String > > e1 : allAtLeastOneGroup.entrySet() ) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment