コード例 #1
0
  @Test
  public void testContainsProperty() {
    grou = new Grounding(topo);

    Property property1 = new Property("p1", new QName("www.uni-stuttgart.de", "wsdlproperty1"));
    Property property2 = new Property("p2", new QName("www.uni-stuttgart.de", "wsdlproperty2"));
    Property property3 = new Property("p3", new QName("www.uni-stuttgart.de", "wsdlproperty1"));

    grou.add(property1);
    grou.add(property2);

    Assert.assertTrue(grou.getProperties().size() == 2);
    Assert.assertTrue(grou.contains(property3));

    grou.add(property3);
    Assert.assertTrue(grou.getProperties().size() == 2);
  }
コード例 #2
0
  /**
   * Read in the grounding file from the given InputStream
   *
   * @param inputStream The {@link InputStream} for reading
   * @param topology The {@link Topology} belonging to the Grounding
   * @return The read {@link Grounding}
   */
  public static Grounding readGrounding(InputStream inputStream, Topology topology) {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader parser;
    Grounding grounding = null;

    try {
      parser = factory.createXMLStreamReader(inputStream);

      if ((parser.getEventType() == XMLStreamConstants.START_DOCUMENT)) {
        parser.nextTag();
      }

      if (parser.getLocalName().equals("grounding")
          && !(parser.getEventType() == XMLStreamConstants.END_ELEMENT)) {

        grounding = new Grounding(topology);
        for (int i = 0; i < parser.getNamespaceCount(); i++) {
          if (parser.getNamespacePrefix(i) != null) {
            grounding
                .getNamespaceMap()
                .addNamespace(parser.getNamespaceURI(i), parser.getNamespacePrefix(i));
          }
        }

        grounding.setTargetNamespace(
            BPEL4ChorReader.getStrAttribute(parser, "targetNamespace", true).toString());

        parser.nextTag();
      }
      if (parser.getLocalName().equals("messageLinks")) {

        parser.nextTag();
        while (parser.hasNext() && parser.getLocalName().equals("messageLink")) {
          if (!(parser.getEventType() == XMLStreamConstants.END_ELEMENT)) {

            grounding
                .getMessageLinks()
                .add(
                    BPEL4ChorReader.readInMessageLinkGD(
                        parser, grounding.getNamespaceMap(), topology));
          }
          parser.nextTag();
        }
        parser.nextTag();
      }

      if (parser.getLocalName().equals("participantRefs")) {
        parser.nextTag();
        while (parser.hasNext() && parser.getLocalName().equals("participantRef")) {
          if (!(parser.getEventType() == XMLStreamConstants.END_ELEMENT)) {

            grounding
                .getParticipantRefs()
                .add(BPEL4ChorReader.readInParticipantRef(parser, grounding.getNamespaceMap()));
          }
          parser.nextTag();
        }
        parser.nextTag();
      }

      if (parser.getLocalName().equals("properties")) {
        parser.nextTag();
        while (parser.hasNext() && parser.getLocalName().equals("property")) {

          if (!(parser.getEventType() == XMLStreamConstants.END_ELEMENT)) {

            grounding
                .getProperties()
                .add(BPEL4ChorReader.readInProperty(parser, grounding.getNamespaceMap()));
          }
          parser.nextTag();
        }
        parser.nextTag();
      }

    } catch (XMLStreamException e) {
      e.printStackTrace();

    } catch (MalformedTLGLSyntaxException e) {
      e.printStackTrace();
    }

    return grounding;
  }