Skip to content

Commit

Permalink
Bug fix in DiffGenerator with cycling schema types.
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavarzi committed Aug 21, 2013
1 parent 5bea005 commit 6b582e4
Show file tree
Hide file tree
Showing 29 changed files with 283 additions and 77 deletions.
6 changes: 4 additions & 2 deletions core/src/main/groovy/com/predic8/schema/All.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

package com.predic8.schema;

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.wstool.creator.*

class All extends ModelGroup {
Expand All @@ -30,8 +32,8 @@ class All extends ModelGroup {
creator.createAll(this, ctx.clone())
}

def compare(generator, other){
generator.compareAll(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareAll(this, other, ctx)
}

String toString(){
Expand Down
7 changes: 5 additions & 2 deletions core/src/main/groovy/com/predic8/schema/Any.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@

package com.predic8.schema;

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.wstool.creator.*

import javax.xml.namespace.QName as JQName

class Any extends SchemaComponent {
Expand Down Expand Up @@ -48,8 +51,8 @@ class Any extends SchemaComponent {
creator.createAny(this, ctx.clone())
}

def compare(generator, other){
generator.compareAny(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareAny(this, other, ctx)
}

String toString(){
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/groovy/com/predic8/schema/Attribute.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

package com.predic8.schema;

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;

import groovy.xml.*

import javax.xml.namespace.QName as JQName

class Attribute extends Declaration {
Expand Down Expand Up @@ -72,8 +76,8 @@ class Attribute extends Declaration {
creator.createAttribute(this, ctx)
}

def compare(generator, other){
generator.compareAttribute(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareAttribute(this, other, ctx)
}

def getElementName(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.predic8.schema

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext;
import com.predic8.soamodel.DiffGeneratorContext;

import groovy.xml.QName

Expand All @@ -38,7 +40,7 @@ class BuiltInSchemaType extends TypeDefinition {
throw new RuntimeException('BuiltInSchemaType have to be created by the given creator itself.')
}

def compare(generator, other){
generator.compareBuiltInSchemaType(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareBuiltInSchemaType(this, other, ctx)
}
}
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/groovy/com/predic8/schema/Choice.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

package com.predic8.schema

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.wstool.creator.*


Expand All @@ -29,8 +31,8 @@ class Choice extends ModelGroup{
creator.createChoice(this, ctx.clone())
}

def compare(generator, other){
generator.compareChoice(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareChoice(this, other, ctx)
}

String toString(){
Expand Down
9 changes: 6 additions & 3 deletions core/src/main/groovy/com/predic8/schema/ComplexContent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
limitations under the License. */

package com.predic8.schema
import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext

import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.schema.restriction.*

import javax.xml.namespace.QName as JQName

import static com.predic8.soamodel.Consts.SCHEMA_NS

class ComplexContent extends SchemaComponent {
Expand Down Expand Up @@ -55,8 +58,8 @@ class ComplexContent extends SchemaComponent {
creator.createComplexContent(this, ctx)
}

def compare(generator, other){
generator.compareComplexContent(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareComplexContent(this, other, ctx)
}


Expand Down
7 changes: 5 additions & 2 deletions core/src/main/groovy/com/predic8/schema/ComplexType.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
package com.predic8.schema;

import groovy.xml.*

import javax.xml.namespace.QName as JQName;

import sun.org.mozilla.classfile.internal.SuperBlock;

import com.predic8.wstool.creator.*
import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext;
import com.predic8.soamodel.DiffGeneratorContext;

class ComplexType extends TypeDefinition {

Expand Down Expand Up @@ -91,8 +94,8 @@ class ComplexType extends TypeDefinition {
creator.createComplexType(this, ctx.clone())
}

def compare(generator, other){
generator.compareComplexType(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareComplexType(this, other, ctx)
}

Sequence getSequence(){
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/groovy/com/predic8/schema/Element.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import org.apache.commons.logging.*

import com.predic8.wstool.creator.*
import com.predic8.schema.creator.*;
import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.xml.util.*

class Element extends Declaration {
Expand Down Expand Up @@ -81,8 +83,8 @@ class Element extends Declaration {
creator.createElement(this, ctx.clone())
}

def compare(generator, other){
generator.compareElement(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareElement(this, other, ctx)
}

String getRequest(formParams){
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/groovy/com/predic8/schema/GroupRef.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
package com.predic8.schema;

import groovy.xml.*

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.wstool.creator.*

import javax.xml.stream.*

class GroupRef extends SchemaComponent{
Expand All @@ -27,8 +31,8 @@ class GroupRef extends SchemaComponent{
creator.createGroupRef(this, ctx)
}

def compare( generator, other ) {
generator.compareGroupRef( this, other )
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareGroupRef( this, other, ctx)
}

public boolean equals(obj) {
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/groovy/com/predic8/schema/Sequence.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package com.predic8.schema;

import com.predic8.wstool.creator.*
import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;

class Sequence extends ModelGroup{

Expand All @@ -28,8 +30,8 @@ class Sequence extends ModelGroup{
creator.createSequence(this, ctx.clone())
}

def compare(generator, other){
generator.compareSequence(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareSequence(this, other, ctx)
}

String toString(){
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/groovy/com/predic8/schema/SimpleContent.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
package com.predic8.schema

import java.util.List

import javax.xml.namespace.QName as JQName

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.schema.restriction.*

import static com.predic8.soamodel.Consts.SCHEMA_NS

class SimpleContent extends SchemaComponent {
Expand Down Expand Up @@ -53,8 +57,8 @@ class SimpleContent extends SchemaComponent {
creator.createSimpleContent(this, ctx)
}

def compare(generator, other){
generator.compareSimpleContent(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareSimpleContent(this, other, ctx)
}
}

8 changes: 5 additions & 3 deletions core/src/main/groovy/com/predic8/schema/SimpleType.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import groovy.xml.QName;

import java.util.List;

import com.predic8.soamodel.AbstractDiffGenerator;
import com.predic8.soamodel.CreatorContext
import com.predic8.soamodel.DiffGeneratorContext;
import com.predic8.wstool.creator.*
import com.predic8.schema.restriction.*
import static com.predic8.soamodel.Consts.SCHEMA_NS

import static com.predic8.soamodel.Consts.SCHEMA_NS
import groovy.xml.*

class SimpleType extends TypeDefinition {
Expand Down Expand Up @@ -81,8 +83,8 @@ class SimpleType extends TypeDefinition {
creator.createSimpleType(this, ctx.clone())
}

def compare(generator, other){
generator.compareSimpleType(this, other)
def compare(AbstractDiffGenerator generator, other, DiffGeneratorContext ctx = new DiffGeneratorContext()){
generator.compareSimpleType(this, other, ctx)
}

String toString(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

package com.predic8.schema.diff

import java.util.List;
import com.predic8.soamodel.*

class BuiltInSchemaTypeDiffGenerator {
class BuiltInSchemaTypeDiffGenerator extends AbstractDiffGenerator {

def generator
def a,b
Expand All @@ -35,5 +34,11 @@ class BuiltInSchemaTypeDiffGenerator {
// }
[]
}


@Override
protected Object updateLabels() {
return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ComplexContentDiffGenerator extends AbstractDiffGenerator{
return [new Difference(description:"${a.derivation.elementName.localPart.capitalize()} ${labelHasChanged}: " , type: 'complexContent',
diffs: [new Difference(description:"ModelGroup has changed from '${a.derivation.model.elementName}' to '${b.derivation.model.elementName}'." , type: 'model', breaks:true, exchange: a.exchange)], exchange: a.exchange)]
}
def lDiffs = a.derivation.model?.compare(generator, b.derivation.model)
def lDiffs = a.derivation.model?.compare(generator, b.derivation.model, ctx.clone())
if(lDiffs){
return [new Difference(description:"${a.derivation.elementName.localPart.capitalize()} ${labelHasChanged}: " , type: 'complexContent', diffs: lDiffs, exchange: a.exchange)]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ComplexTypeDiffGenerator extends UnitDiffGenerator{
}

List<Difference> compareUnit(){
def lDiffs = new AnnotationDiffGenerator(a: a.annotation, b: b.annotation, generator: generator).compare()
def lDiffs = new AnnotationDiffGenerator(a: a.annotation, b: b.annotation, generator: generator).compare()
lDiffs.addAll( compareModel())
lDiffs
}
Expand All @@ -45,7 +45,7 @@ class ComplexTypeDiffGenerator extends UnitDiffGenerator{
} else if(a.model) {
a.model.exchange.addAll(a.exchange)
b.model?.exchange?.addAll(b.exchange)
lDiffs.addAll(a.model.compare(generator, b.model ))
lDiffs.addAll(a.model.compare(generator, b.model, ctx.clone()))
}

lDiffs.addAll(generator.compareAttributes(a, b))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class ElementDiffGenerator extends UnitDiffGenerator {
}

List<Difference> compareUnit(){
log.debug("compareElement")
def lDiffs = []
log.debug("compareElement")
def lDiffs = []
lDiffs.addAll(generator.compareAnnotation(a.annotation, b.annotation))
lDiffs.addAll(compareType())
lDiffs.addAll(compareMinMaxOccurs())
Expand All @@ -73,20 +73,24 @@ class ElementDiffGenerator extends UnitDiffGenerator {
lDiffs
}

//Recursion is possible if an element in the embedded type references a complexType, which returns to the wrapping element of the embedded type.
private List<Difference> compareEmbeddedType() {
a.embeddedType?.exchange.addAll(a.exchange)
b.embeddedType?.exchange.addAll(b.exchange)
a.embeddedType?.compare(generator, b.embeddedType) ?: []
a.embeddedType?.compare(generator, b.embeddedType, ctx.clone()) ?: []
}

//Recursion is possible if an element references a type, which returns to the element in further steps.
List<Difference> compare4WSDL() {
def diffs = []
def aT = a.schema.getType(a.type)
def bT = b.schema.getType(b.type)
if(aT && bT &&a.type == b.type){
if(aT && bT && a.type == b.type){
//exchange marks the message direction in the using wsdl:operation
aT?.exchange.addAll(a.exchange)
bT?.exchange.addAll(b.exchange)
diffs.addAll(aT.compare(generator, bT))

diffs.addAll(aT.compare(generator, bT, ctx.clone()))
}
diffs
}
Expand Down
Loading

0 comments on commit 6b582e4

Please sign in to comment.