Package nexj.core.meta.workflow

Examples of nexj.core.meta.workflow.FlowMacro$Argument


    */
   protected void loadFlowMacro(Element macroElement, String sMacroName)
   {
      XMLMetadataHelper.verifyRootElement(macroElement, "Action");

      final FlowMacro macro = new FlowMacro(sMacroName);

      macro.setWorkflowCompatible(XMLUtil.getBooleanAttr(macroElement, "workflow", macro.isWorkflowCompatible()));
      macro.setServiceCompatible(XMLUtil.getBooleanAttr(macroElement, "service", macro.isServiceCompatible()));

      XMLUtil.withFirstChildElement(macroElement, "Arguments", false, new XMLUtil.ElementHandler()
      {
         public void handleElement(Element argumentsElement)
         {
            XMLUtil.forEachChildElement(argumentsElement, "Argument", m_helper.new ElementHandler("argument")
            {
               protected void handleElement(Element argumentElement, String sName)
               {
                  FlowMacro.Argument arg = new FlowMacro.Argument(sName);
                  String sTypeName = XMLUtil.getReqStringAttr(argumentElement, "type");

                  arg.setType((sTypeName.equals("list")) ? null : Primitive.parse(sTypeName));
                  arg.setDefault(m_helper.parse(XMLUtil.getStringAttr(argumentElement, "default"),
                     false, macro.getTextPositionMap(), arg.getDefault(), m_metadata.getGlobalEnvironment()));

                  macro.addArgument(arg);
               }
            });
         }
      });

      XMLUtil.withFirstChildElement(macroElement, "Script", false, new XMLUtil.ElementHandler()
      {
         public void handleElement(Element script)
         {
            macro.setBody((Pair)m_helper.parse(m_helper.getElementValue(script),
               true, macro.getTextPositionMap(), null, m_metadata.getGlobalEnvironment()));
         }
      });

      macro.compile(m_machine);

      m_metadata.addFlowMacro(macro);
   }
View Full Code Here


    */
   public static FlowMacroScript loadFlowMacroScript(Element stepElement, String sStepName, Activity activity,
      XMLMetadataHelper helper, Machine machine, boolean bFull)
   {
      Flow flow = activity.getFlow();
      FlowMacro macro = flow.getMetadata().findFlowMacro(stepElement.getNodeName());

      if (macro == null)
      {
         return null;
      }

      if (flow instanceof Workflow && !macro.isWorkflowCompatible() ||
         flow instanceof Service && !macro.isServiceCompatible())
      {
         throw new MetadataException("err.meta." + flow.getPropName() + ".incompatibleMacro",
            new Object[]{macro.getName(), flow.getFullName()});
      }

      FlowMacroScript script = new FlowMacroScript(sStepName);

      script.setActivity(activity);
      script.setMacro(macro);

      NamedNodeMap attributeMap = stepElement.getAttributes();
      Set attributeSet = new HashHolder(attributeMap.getLength());

      for (int i = 0; i < attributeMap.getLength(); ++i)
      {
         attributeSet.add(attributeMap.item(i).getNodeName());
      }

      Object[] args = new Object[macro.getArgumentCount()];

      for (int i = 0, n = macro.getArgumentCount(); i < n; ++i)
      {
         FlowMacro.Argument arg = macro.getArgument(i);
         String sValue = stepElement.getAttribute(arg.getName());

         if (arg.getType() == null || arg.getType() == Primitive.ANY)
         {
            Object value = helper.parse(sValue, arg.getType() == null,
               flow.getPosMap(), Undefined.VALUE,
               machine.getGlobalEnvironment());

            if (bFull)
            {
               script.setArgumentValue(i, value);
            }

            args[i] = (value == Undefined.VALUE) ? arg.getDefault() : value;
         }
         else
         {
            if (sValue == null)
            {
               args[i] = arg.getDefault();

               if (bFull)
               {
                  script.setArgumentValue(i, Undefined.VALUE);
               }
            }
            else
            {
               args[i] = arg.getType().convert(sValue);

               if (bFull)
               {
                  script.setArgumentValue(i, args[i]);
               }
            }
         }

         if (args[i] == Undefined.VALUE)
         {
            throw new MetadataException("err.meta." + flow.getPropName() + ".missingMacroArg",
               new Object[]{arg.getName(), macro.getName(), flow.getFullName()});
         }

         attributeSet.remove(arg.getName());
      }

      attributeSet.remove("name");
      attributeSet.remove("caption");
      attributeSet.remove("description");
      attributeSet.remove("layout");

      if (attributeSet.size() != 0)
      {
         throw new MetadataException("err.meta." + flow.getPropName() + ".macroArgLookup",
            new Object[]{attributeSet.iterator().next(), macro.getName(), flow.getFullName()});
      }

      script.setBody(new Pair(machine.invoke(macro.getFunction(), args)));

      Lookup flowPosMap = flow.getPosMap();
      Lookup macroPosMap = macro.getTextPositionMap();

      if (flowPosMap != null && macroPosMap != null)
      {
         for (Lookup.Iterator itr = macroPosMap.iterator(); itr.hasNext();)
         {
View Full Code Here

   public void exportStep(Step step) throws IOException
   {
      if (step instanceof FlowMacroScript)
      {
         FlowMacroScript script = (FlowMacroScript)step;
         FlowMacro macro = script.getMacro();

         openStepElement(step, macro.getName());

         for (int i = 0, n = macro.getArgumentCount(); i < n; ++i)
         {
            Object value = script.getArgumentValue(i);

            if (value == Undefined.VALUE)
            {
               continue;
            }

            FlowMacro.Argument arg = macro.getArgument(i);

            if (arg.getType() == null || arg.getType() == Primitive.ANY)
            {
               exportSExpression(value, arg.getType() == null,
                  false, arg.getDefault(), arg.getName());
View Full Code Here

    * @return The flow macro object.
    * @throws MetadataLookupException if the flow macro does not exist.
    */
   public FlowMacro getFlowMacro(String sName)
   {
      FlowMacro flowMacro = (FlowMacro) m_flowMacroMap.get(sName);

      if (flowMacro != null)
      {
         return flowMacro;
      }
View Full Code Here

    gBuilder.withOption(oBuilder.reset().withId(OPTION_QS).withShortName("qs").withLongName("querysilent").withDescription(
        "Silent Query the status of an NT service or Unix daemon").create());
    gBuilder.withOption(oBuilder.reset().withId(OPTION_QX).withShortName("qx").withLongName("queryposix").withDescription(
        "Query the status of a posix daemon. Return status as exit code").create());

    Argument pid = aBuilder.reset().withName(PID).withDescription("PID of process to reconnect to").withMinimum(1).withMaximum(1).withValidator(
        NumberValidator.getIntegerInstance()).create();

    gBuilder.withOption(oBuilder.reset().withId(OPTION_N).withShortName("n").withLongName("reconnect").withDescription(
        "recoNnect to existing application").withArgument(pid).create());

    Argument pid2 = aBuilder.reset().withName(PID).withDescription("PID of process to reconnect to").withMinimum(1).withMaximum(1).withValidator(
        NumberValidator.getIntegerInstance()).create();

    Argument defaultFile = aBuilder.reset().withName(DEFAULT_FILE).withDescription("Default Configuration File").withMinimum(0).withMaximum(1)
        .withValidator(VFSFileValidator.getExistingFileInstance().setBase(".")).create();
    /*
     * GroupBuilder childGbuilder = new GroupBuilder(); DefaultOptionBuilder
     * childoObuilder = new DefaultOptionBuilder("-", "--", true);
     *
 
View Full Code Here

                                    String defaultValue) {
    ArgumentBuilder argBuilder = new ArgumentBuilder().withName(name).withMinimum(1).withMaximum(1);
    if (defaultValue != null) {
      argBuilder = argBuilder.withDefault(defaultValue);
    }
    Argument arg = argBuilder.create();
    return new DefaultOptionBuilder().withLongName(name).withRequired(required).withShortName(shortName)
        .withArgument(arg).withDescription(description).create();
  }
View Full Code Here

    }
  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required){
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      create();
    return builder.
View Full Code Here

  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required, Validator validator){
   
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      withValidator(validator).
      create();
View Full Code Here

    }
  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required){
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      create();
    return builder.
View Full Code Here

  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required, Validator validator){
   
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      withValidator(validator).
      create();
View Full Code Here

TOP

Related Classes of nexj.core.meta.workflow.FlowMacro$Argument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.