001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.properties;
021:
022: import java.util.Collection;
023: import org.netbeans.modules.xml.schema.model.GlobalElement;
024: import org.netbeans.modules.xml.schema.model.GlobalType;
025: import org.netbeans.modules.xml.wsdl.model.Message;
026: import org.netbeans.modules.xml.wsdl.model.Part;
027: import org.netbeans.modules.xml.wsdl.model.WSDLComponent;
028: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PropertyAlias;
029: import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Query;
030: import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
031:
032: /**
033: * Keeps information about selected type and message part and query for a Property Alias.
034: * The message part is pertinent only in case the type is Message.
035: *
036: * @author nk160297
037: */
038: public class PropAliasSelectionContainer {
039:
040: private TypeContainer myTypeContainer;
041: private Part myMsgPart;
042: private String myQueryContent;
043:
044: public PropAliasSelectionContainer(PropertyAlias propAlias) {
045: boolean processed = false;
046: //
047: NamedComponentReference<Message> msgRef = propAlias
048: .getMessageType();
049: if (msgRef != null) {
050: Message msg = msgRef.get();
051: if (msg != null) {
052: myTypeContainer = new TypeContainer(msg);
053: processed = true;
054: //
055: // Look for a Part by the name
056: String partName = propAlias.getPart();
057: Collection<Part> parts = msg.getParts();
058: for (Part part : parts) {
059: if (part.getName().equals(partName)) {
060: myMsgPart = part;
061: break;
062: }
063: }
064: }
065: }
066: //
067: if (!processed) {
068: NamedComponentReference<GlobalElement> elementRef = propAlias
069: .getElement();
070: if (elementRef != null) {
071: GlobalElement element = elementRef.get();
072: if (element != null) {
073: myTypeContainer = new TypeContainer(element);
074: processed = true;
075: }
076: }
077: }
078: //
079: if (!processed) {
080: NamedComponentReference<GlobalType> typeRef = propAlias
081: .getType();
082: if (typeRef != null) {
083: GlobalType type = typeRef.get();
084: if (type != null) {
085: myTypeContainer = new TypeContainer(type);
086: processed = true;
087: }
088: }
089: }
090: //
091: Query query = propAlias.getQuery();
092: if (query != null) {
093: myQueryContent = query.getContent();
094: }
095: }
096:
097: public PropAliasSelectionContainer(Part msgPart, String queryContent) {
098: myMsgPart = msgPart;
099: //
100: WSDLComponent msg = msgPart.getParent();
101: assert msg instanceof Message;
102: myTypeContainer = new TypeContainer((Message) msg);
103: //
104: myQueryContent = queryContent;
105: }
106:
107: public PropAliasSelectionContainer(Message msg, Part msgPart,
108: String queryContent) {
109: myTypeContainer = new TypeContainer(msg);
110: myMsgPart = msgPart;
111: myQueryContent = queryContent;
112: }
113:
114: public PropAliasSelectionContainer(TypeContainer typeContainer,
115: String queryContent) {
116: myTypeContainer = typeContainer;
117: myQueryContent = queryContent;
118: }
119:
120: public TypeContainer getTypeContainer() {
121: return myTypeContainer;
122: }
123:
124: public Part getMessagePart() {
125: return myMsgPart;
126: }
127:
128: public String getQueryContent() {
129: return myQueryContent;
130: }
131: }
|