/**
  * @param path
  * @return
  */
 private boolean handleStructureDataMapping(Path path) {
   getTopLevelInputControllerMap()
       .put(
           path.getId(),
           formGenerator.generateStructurePanel(
               getFullPathInputControllerMap(), getRootContainer(), path));
   return true;
 }
  /**
   * @param path
   * @return
   */
  private boolean handleListDataMapping(Path path) {
    ListInputController listInputController = new ListInputController(path);
    formGenerator.addListComponent(getRootContainer(), path);

    getFullPathInputControllerMap().put("/" + path.getId(), listInputController);
    getTopLevelInputControllerMap().put(path.getId(), listInputController);

    return true;
  }
  /**
   * @param path
   * @return
   */
  private boolean handleEnumerationPath(Path path) {
    PrimitiveInputController inputController =
        new PrimitiveInputController(path, new PrimitiveInputControllerDataTypeAdapter(path));
    FormInput input = formGenerator.addEnumerationInput(getRootContainer(), inputController);
    getRootContainer().getInputs().add(input);

    getFullPathInputControllerMap().put("/" + path.getId(), inputController);
    getTopLevelInputControllerMap().put(path.getId(), inputController);

    return true;
  }
  /**
   * @param documentPath
   * @param dataMapping
   * @return
   */
  private boolean handleDocumentPath(DocumentPath documentPath, DataMapping dataMapping) {
    DocumentInputController docInputController =
        new IppDocumentInputController(
            documentPath, activityInstance, dataMapping, documentInputEventHandler);

    formGenerator.addDocumentInput(
        getFullPathInputControllerMap(), getRootContainer(), docInputController);

    getFullPathInputControllerMap().put("/" + documentPath.getId(), docInputController);
    getTopLevelInputControllerMap().put(documentPath.getId(), docInputController);

    return true;
  }
  /**
   * @param systemPath
   * @return
   */
  private boolean handleSystemPath(IppSystemPath systemPath) {
    PrimitiveInputController inputController =
        new PrimitiveInputController(
            systemPath, new PrimitiveInputControllerDataTypeAdapter(systemPath));

    FormInput input = null;
    if (systemPath.isEnumeration()) {
      input = formGenerator.addEnumerationInput(getRootContainer(), inputController);
    } else if (systemPath.isPrimitive()) {
      input = formGenerator.addPrimitiveInput(getRootContainer(), inputController);
    }

    if (null != input) {
      getRootContainer().getInputs().add(input);
      getFullPathInputControllerMap().put("/" + systemPath.getId(), inputController);
      getTopLevelInputControllerMap().put(systemPath.getId(), inputController);

      return true;
    } else {
      return false;
    }
  }
 /** @return */
 public String generateMarkup() {
   return formGenerator.generateMarkup(
       ((JsfStructureContainer) getRootContainer()).getRootGrid(), null);
 }
  /*
   * Generates the top level panel for all Data Mappings of the Activity.
   */
  @SuppressWarnings("unchecked")
  public void generateForm() {
    List<Object> allOutMappings = getApplicationContext().getAllOutDataMappings();
    List<Object> allInMappings = getApplicationContext().getAllInDataMappings();

    // Process OUT Mappings first
    List<Object> allMappings = new ArrayList<Object>();
    allMappings.addAll(allOutMappings);
    allMappings.addAll(allInMappings);

    // Process All IN/OUT Mappings and collect all of them in ManualActivityPath
    Path path = null;
    ManualActivityPath manualActivityPath =
        new ManualActivityPath("MA" + activityInstance.getOID(), false);
    Map<Path, DataMapping> pathDataMappingMap = new HashMap<Path, DataMapping>();
    Map<String, DataMapping> dataMappingMap = new HashMap<String, DataMapping>();
    for (Object object : allMappings) {
      DataMapping dataMapping = (DataMapping) object;

      if (dataMappingMap.containsKey(dataMapping.getId())) {
        continue;
      }

      dataMappingMap.put(dataMapping.getId(), dataMapping);
      if (trace.isDebugEnabled()) {
        trace.debug(
            "Processing Data Mapping - " + dataMapping.getId() + ":" + dataMapping.getName());
      }

      // Handle Data Mapping as per Type
      if (ModelUtils.isSystemDefinedData(dataMapping)) {
        path = createSystemDataMapping(dataMapping, manualActivityPath);
      } else if (ModelUtils.isDMSType(getModel(), dataMapping)) {
        path = createDMSDataMapping(dataMapping, allInMappings, manualActivityPath);
      } else if (ModelUtils.isEnumerationType(getModel(), dataMapping)) {
        path = createStructureDataMapping(dataMapping, manualActivityPath);
      } else if (ModelUtils.isPrimitiveType(getModel(), dataMapping)) {
        path = createPrimitiveDataMapping(dataMapping, manualActivityPath);
      } else if (ModelUtils.isStructuredType(getModel(), dataMapping)) {
        path = createStructureDataMapping(dataMapping, manualActivityPath);
      }

      if (null != path) {
        manualActivityPath.getChildPaths().add(path);
        pathDataMappingMap.put(path, dataMapping);
      } else {
        trace.warn(
            "Skipping Data Mapping - Not supported - "
                + dataMapping.getId()
                + ":"
                + dataMapping.getName());
      }
    }

    // Set Label Provider along with required data for I18N
    formGenerator.setLabelProvider(new ManualActivityLabelProvider(getModel(), pathDataMappingMap));

    setRootContainer(formGenerator.createRootComponent());

    // Process ManualActivityPath and generate form
    processManualActivityPath(manualActivityPath, pathDataMappingMap);

    // Debug Information
    if (trace.isDebugEnabled()) {
      trace.debug("Full Path Map = " + getFullPathInputControllerMap());
      trace.debug("Top Level Map = " + getTopLevelInputControllerMap());
      trace.debug("Markup:\n" + generateMarkup());
    }
  }