예제 #1
0
  /**
   * This method converts the supplied CDL type into a Scribble model object.
   *
   * @param context The converters context
   * @param scribbleType The Scribble target type
   * @param cdlType The CDL type to be converted
   * @return The converted Scribble model object
   */
  public ModelObject parse(ParserContext context, Class<?> scribbleType, CDLType cdlType) {
    org.scribble.protocol.model.Parallel ret = new org.scribble.protocol.model.Parallel();
    org.pi4soa.cdl.Parallel cdl = (org.pi4soa.cdl.Parallel) cdlType;

    Annotation scannotation = new Annotation(AnnotationDefinitions.SOURCE_COMPONENT);

    scannotation
        .getProperties()
        .put(AnnotationDefinitions.ID_PROPERTY, CDLTypeUtil.getURIFragment(cdl));
    ret.getAnnotations().add(scannotation);

    // Process all of the activities within the
    // choreography
    java.util.Iterator<org.pi4soa.cdl.Activity> actiter = cdl.getActivities().iterator();
    while (actiter.hasNext()) {
      org.pi4soa.cdl.Activity act = actiter.next();

      ParserRule rule =
          ParserRuleFactory.getConverter(org.scribble.protocol.model.Activity.class, act);

      if (rule != null) {

        context.pushState();

        org.scribble.protocol.model.Activity activity =
            (org.scribble.protocol.model.Activity)
                rule.parse(context, org.scribble.protocol.model.Activity.class, act);

        if (activity != null) {
          if (activity instanceof Block) {
            ret.getPaths().add((Block) activity);
          } else {
            Block block = new Block();
            block.getContents().add(activity);
            ret.getPaths().add(block);
          }
        }

        context.popState();
      }
    }

    return (ret);
  }