1 19 20 package org.netbeans.modules.xml.wsdl.model.extensions.bpel.validation.semantic; 21 22 import java.util.ArrayList ; 23 import java.util.List ; 24 import org.netbeans.modules.xml.schema.model.GlobalElement; 25 import org.netbeans.modules.xml.schema.model.GlobalType; 26 import org.netbeans.modules.xml.wsdl.model.Message; 27 import org.netbeans.modules.xml.wsdl.model.PortType; 28 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.CorrelationProperty; 29 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType; 30 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PropertyAlias; 31 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role; 32 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.validation.StringAttribute; 33 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.validation.ValidationVisitor; 34 import org.netbeans.modules.xml.xam.Component; 35 import org.netbeans.modules.xml.xam.dom.NamedComponentReference; 36 import org.netbeans.modules.xml.xam.spi.Validator; 37 import org.netbeans.modules.xml.xam.spi.Validator.ResultItem; 38 import org.openide.util.NbBundle; 39 40 44 public class BPELExtensionSemanticVisitor extends ValidationVisitor { 45 46 public static final String VAL_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE = "VAL_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE"; public static final String FIX_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE = "FIX_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE"; 49 public static final String VAL_INVALID_PROPERTY_ALIAS_ELEMENT = "VAL_INVALID_PROPERTY_ALIAS_ELEMENT"; public static final String FIX_INVALID_PROPERTY_ALIAS_ELEMENT = "FIX_INVALID_PROPERTY_ALIAS_ELEMENT"; 52 public static final String VAL_INVALID_PROPERTY_ALIAS_TYPE = "VAL_INVALID_PROPERTY_ALIAS_TYPE"; public static final String FIX_INVALID_PROPERTY_ALIAS_TYPE = "FIX_INVALID_PROPERTY_ALIAS_TYPE"; 55 public static final String VAL_INVALID_PORT_TYPE = "VAL_INVALID_PORT_TYPE"; public static final String FIX_INVALID_PORT_TYPE = "FIX_INVALID_PORT_TYPE"; 58 public static final String VAL_INVALID_PARTNERLINK_TYPE = "VAL_INVALID_PARTNERLINK_TYPE"; public static final String FIX_INVALID_PARTNERLINK_TYPE = "FIX_INVALID_PARTNERLINK_TYPE"; 61 public static final String VAL_INVALID_PROPERTY_NAME = "VAL_INVALID_PROPERTY_NAME"; 62 public static final String FIX_INVALID_PROPERTY_NAME = "FIX_INVALID_PROPERTY_NAME"; 63 64 65 private Validator mValidator; 66 67 public BPELExtensionSemanticVisitor(Validator validator) { 68 this.mValidator = validator; 69 init(); 70 } 71 72 public void visit(PartnerLinkType c) { 73 Role role1 = c.getRole1(); 74 if(role1 != null) { 75 visit(role1); 76 } 77 78 Role role2 = c.getRole2(); 79 if(role2 != null) { 80 visit(role2); 81 } 82 83 if(c.getChildren(Role.class).size() > 2) { 85 addNewResultItem(Validator.ResultType.ERROR, 86 c, 87 NbBundle.getMessage(getClass(), VAL_INVALID_PARTNERLINK_TYPE), 88 NbBundle.getMessage(getClass(), FIX_INVALID_PARTNERLINK_TYPE)); 89 } 90 } 91 92 public void visit(Role c) { 93 NamedComponentReference<PortType> portTypeRef = c.getPortType(); 95 String portType = c.getAttribute(new StringAttribute(Role.PORT_TYPE_PROPERTY)); 96 if((portTypeRef== null || portTypeRef.get() == null) && portType != null) { 97 98 addNewResultItem(Validator.ResultType.ERROR, 99 c, 100 NbBundle.getMessage(getClass(), VAL_INVALID_PORT_TYPE, portType), 101 NbBundle.getMessage(getClass(), FIX_INVALID_PORT_TYPE, portType)); 102 } 103 } 104 105 106 public void visit(PropertyAlias c) { 107 108 NamedComponentReference<CorrelationProperty> propertyRef = c.getPropertyName(); 110 String property = c.getAttribute(new StringAttribute(PropertyAlias.PROPERTY_NAME_PROPERTY)); 111 if((propertyRef == null || propertyRef.get() == null) && property != null) { 112 addNewResultItem(Validator.ResultType.ERROR, 113 c, 114 NbBundle.getMessage(getClass(), VAL_INVALID_PROPERTY_NAME, property), 115 NbBundle.getMessage(getClass(), FIX_INVALID_PROPERTY_NAME, property)); 116 117 } 118 119 NamedComponentReference<Message> msgRef = c.getMessageType(); 121 String messageType = c.getAttribute(new StringAttribute(PropertyAlias.MESSAGE_TYPE_PROPERTY)); 122 if((msgRef== null || msgRef.get() == null) && messageType != null) { 123 124 addNewResultItem(Validator.ResultType.ERROR, 125 c, 126 NbBundle.getMessage(getClass(), VAL_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE, messageType), 127 NbBundle.getMessage(getClass(), FIX_INVALID_PROPERTY_ALIAS_MESSAGE_TYPE, messageType)); 128 } 129 130 NamedComponentReference<GlobalElement> geRef = c.getElement(); 132 String element = c.getAttribute(new StringAttribute(PropertyAlias.ELEMENT_PROPERTY)); 133 if((geRef == null || geRef.get() == null) && element != null) { 134 135 addNewResultItem(Validator.ResultType.ERROR, 136 c, 137 NbBundle.getMessage(getClass(), VAL_INVALID_PROPERTY_ALIAS_ELEMENT, element), 138 NbBundle.getMessage(getClass(), FIX_INVALID_PROPERTY_ALIAS_ELEMENT, element)); 139 } 140 141 NamedComponentReference<GlobalType> gtRef = c.getType(); 143 String type = c.getAttribute(new StringAttribute(PropertyAlias.TYPE_PROPERTY)); 144 if((gtRef == null || gtRef.get() == null) && type != null) { 145 146 addNewResultItem(Validator.ResultType.ERROR, 147 c, 148 NbBundle.getMessage(getClass(), VAL_INVALID_PROPERTY_ALIAS_TYPE, type), 149 NbBundle.getMessage(getClass(), FIX_INVALID_PROPERTY_ALIAS_TYPE, type)); 150 } 151 152 153 154 } 155 156 157 165 void addNewResultItem( Validator.ResultType type, 166 Component component, 167 String desc, 168 String correction ) 169 { 170 ResultItem item = new Validator.ResultItem(mValidator, 171 type, 172 component, 173 desc + correction); 174 getResultItems().add(item); 175 } 176 177 178 179 } 180 | Popular Tags |