Package org.uengine.contexts

Examples of org.uengine.contexts.HtmlFormContext


       
       
        //TODO: 1. 서버에 있는 Form html을 읽어서 file로 저장.
        //FIXME: production 버전을 갖고 와야함
        FormActivity formActivity = (FormActivity) getActivity();
        HtmlFormContext formContext = (HtmlFormContext) formActivity.getVariableForHtmlFormContext().getDefaultValue();
       
        String formDefID[] = formContext.getFormDefId().split("@");


        openedForm = new OpenedForm();
        openedForm.formDefVerId = formDefID[1];
        openedForm.formName = formDefID[0].replaceAll("[\\[||\\]]","");
        openedForm.launcher = launcher; //may result huge memory resident in the static variable "openedForms"
       
        String fileName = openedForm.formName + ".jsp";
        String tempFilePath = System.getProperty("temp.path", "C:\\uengine\\");

        File newFile = new File(tempFilePath);
        if(!newFile.exists()){
          newFile.mkdirs();
        }
       
        tempFilePath = tempFilePath + File.separatorChar + fileName;

        openedForm.localFilePath = tempFilePath;
   
        InputStream is;
        try {
          is = ProcessDesigner.getInstance().getClientProxy().showFormDefinitionWithVersionId(formDefID[1]);
          File outFile = new File(tempFilePath);
          BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile));
          /*if(is!=null){
            byte [] buf = new byte[1024];
            int len;
            while ((len = is.read(buf)) > 0) {
              bos.write(buf, 0, len);
            }
            is.close();
              }
          bos.close();*/
         
          if(is!=null)
            org.uengine.util.UEngineUtil.copyStream(is, bos);
         
          openedForm.lastModified = outFile.lastModified();
          //openedForm.
         
        } catch (Exception e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
        String tool = System.getProperty("form.editor", "notepad");
       
        //review: this command will work only in Windows
        launcher.run(
          "cmd /c \"" + tool + "\" " + tempFilePath
        );
       
        openedForms.put(openedForm.formName, openedForm);
       
        // keep only one window listener for all the form designers there
        if(windowsFocusListener==null){
          windowsFocusListener = new WindowFocusListener(){

              public void windowGainedFocus(WindowEvent e) {
               
                try {

                  final Type deployOrNot = new Type("Select forms to deploy");
                  final Instance deployInstance = deployOrNot.createInstance();

                  new ForLoop(){

                    public void logic(Object target) {
                      OpenedForm openedForm = (OpenedForm) target;
                     
                      File file = new File(openedForm.localFilePath);
                      if(openedForm.lastModified != file.lastModified()){
                        deployOrNot.addFieldDescriptor(new FieldDescriptor(openedForm.formName, Boolean.class, null, null));
                        deployInstance.setFieldValue(openedForm.formName, true);
                        openedForm.lastModified = file.lastModified();
                      }
                    }
                   
                  }.run(openedForms);
                 
                  if(deployOrNot.getFieldDescriptors()==null || deployOrNot.getFieldDescriptors().length == 0) return;
                 
                  InputForm inputForm = new InputForm(deployOrNot){
                    public void onSaveOK(final Instance rec, JDialog dialog) {

                      dialog.dispose();
                     
                      SwingUtilities.invokeLater(new Runnable(){

                        public void run() {
                          new ProgressDialog("Deploy", ProcessDesigner.getInstance()){

                            public void run() throws Exception {
                              FieldDescriptor[] fds = deployOrNot.getFieldDescriptors();

                              for(int i=0; i<deployOrNot.getFieldDescriptors().length; i++){
                               
                                String fieldName = fds[i].getName();
                                Boolean value = (Boolean)rec.getFieldValue(fieldName);
                                if(value.booleanValue()){
                                  OpenedForm of = (OpenedForm) openedForms.get(fieldName);
                                  deployForm(of);
                                }
                              }
                            }
                           
                          }.show();
                        }
                       
                      });
                     
                    }

                    public void onUpdateOK(Instance rec, JDialog dialog) {
                      onUpdateOK(rec, dialog);
                    }
                  };
                 
                  inputForm.setInstance(deployInstance);
                 
                  inputForm.postInputDialog(ProcessDesigner.getInstance(), "Deploy", "Deploy");
                 
                } catch (Exception e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
              }

              public void windowLostFocus(WindowEvent e) {
                // TODO Auto-generated method stub
               
              }

          };
         
          ProcessDesigner.getInstance().addWindowFocusListener(windowsFocusListener);
        }
       
      }
     
    });
   
    previewForm.addActionListener(new ActionListener(){
      public void actionPerformed(ActionEvent e) {
        FormActivity formActivity = (FormActivity) getActivity();
        HtmlFormContext formContext = (HtmlFormContext) formActivity.getVariableForHtmlFormContext().getDefaultValue();
        String[] formDefID = formContext.getFormDefId().split("@");
        String host = ProcessDesigner.getInstance().getClientProxy().getHttpClient().getHost();
        int port = ProcessDesigner.getInstance().getClientProxy().getHttpClient().getPort();
        ProcessDesigner.getInstance().openNativeBrowser("http://" + host + ":" + port + GlobalContext.WEB_CONTEXT_ROOT + "/processmanager/previewFormDefinition.jsp?defVerId=" + formDefID[1]);
      }     
    });
View Full Code Here


    super.afterComplete(instance);
  }
 
  protected void mappingOut(ProcessInstance instance) throws Exception{
    // load up the HtmlFormContext
    HtmlFormContext formContext = (HtmlFormContext) getVariableForHtmlFormContext().get(instance, "");
   
    ParameterContext[] params = getMappingContext().getMappingElements();
    if (params != null) {
      for (int i = 0; i < params.length; i++) {
        ParameterContext param = params[i];
View Full Code Here

    if("true".equals(GlobalContext.getPropertyString("org.uengine.kernel.formactivity.run_select_activities_before_formactivity"))){
      //TODO run again the before data gathering activities located previously
    }
   
    Map mappedResult = new HashMap();
    HtmlFormContext formContext = instance == null ? (HtmlFormContext)(getVariableForHtmlFormContext().getDefaultValue()) : (HtmlFormContext)(getVariableForHtmlFormContext().get(instance, ""));
   
    if(formContext == null) {
      return mappedResult;
    }
   
    String status = instance.getStatus(getTracingTag());
   
    if (Activity.STATUS_READY.equals(status) ||
        Activity.STATUS_RUNNING.equals(status) ||
        Activity.STATUS_TIMEOUT.equals(status)) {
     
      MappingContext mappingContext = getMappingContext();
      ParameterContext[] params = mappingContext.getMappingElements();//getVariableBindings();
     
      if(params != null && instance != null){
        //String script = "";
        String objName = null;
        Serializable objValue = null;
        for (int i = 0; i < params.length; i++) {
          ParameterContext param = params[i];
 
          String targetFormField = param.getArgument().getText();
           
          targetFormField = targetFormField.replace('.','@');
          String [] targetFormFieldName = targetFormField.split("@");
         
          if(getVariableForHtmlFormContext().getName().equals(targetFormFieldName[0])){
            objName = targetFormFieldName[1];
           
            if(param.getTransformerMapping()!=null){
                       
              Map options = new HashMap();
              options.put(org.uengine.processdesigner.mapper.Transformer.OPTION_KEY_OUTPUT_ARGUMENT, param.getTransformerMapping().getLinkedArgumentName() );
              options.put(org.uengine.processdesigner.mapper.Transformer.OPTION_KEY_FORM_FIELD_NAME, objName);
             
              objValue = (Serializable) param.getTransformerMapping().getTransformer().letTransform(instance, options);
             
            }else{
             
              String sourceProcessVariable = param.getVariable().getName();
 
              if(sourceProcessVariable.startsWith("["))
                objValue = (Serializable) instance.getBeanProperty(sourceProcessVariable);
              else{
                ProcessVariableValue pvv = instance.getMultiple("", sourceProcessVariable);
                pvv.beforeFirst();
                if(pvv.size()>1){
                  Object values[] = new String[pvv.size()];
                  int j=0;
                 
                  do {
                    Object objTmp = pvv.getValue();
                    StringBuffer strTmpValue = new StringBuffer();
                   
                    if (objTmp != null) {
                      if (objTmp.getClass().isArray()) {
                        for (String strTmp : (String[]) objTmp) {
                          strTmpValue.append(strTmp).append(";");
                        }
                      } else {
                        strTmpValue.append(pvv.getValue().toString());
                      }
                    }
                   
                    values[j++] = strTmpValue.toString();
  //                  values[j++] = pvv.getValue();
                  } while (pvv.next());
                 
                  objValue = values;
                }else{
                 
                  objValue = pvv.getValue();
                }
              }
            }
                     
            mappedResult.put(objName.toLowerCase(), objValue);
          }
        }
      }
    }
   
    if (formContext.getFilePath() != null) {
      if(formContext.getValueMap() == null){
        formContext.loadValueMap();
      }
      mappedResult.putAll(formContext.getValueMap());
    }
   
    return mappedResult;
  }
View Full Code Here

        }
      }
    }
   
    if(isSimulation) {
      HtmlFormContext newFormCtx = new HtmlFormContext();
      newFormCtx.setValueMap(valueMap);
     
      getVariableForHtmlFormContext().set(instance, "", newFormCtx);
     
      return;
    }

   
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSS", Locale.KOREA);
   
    String filePath = UEngineUtil.getCalendarDir();
    File dirToCreate = new File(FILE_SYSTEM_DIR + filePath);
    dirToCreate.mkdirs();
 
    String datePrefix = sdf.format(new Date());
    String fileName = instance.getInstanceId() +"_"+datePrefix + ".xml";
    File newFile = new File(FILE_SYSTEM_DIR + filePath+"/"+fileName);
    FileOutputStream fos = new FileOutputStream(newFile);
    GlobalContext.serialize(valueMap, fos, HashMap.class);
    fos.close();
   
    HtmlFormContext formDefInfo = (HtmlFormContext)getVariableForHtmlFormContext().getDefaultValue();
    String[] formDefID = formDefInfo.getFormDefId().split("@");
    String formDefinitionVersionId = (String) valueMap.get("formdefinitionversionid");
    if(!UEngineUtil.isNotEmpty(formDefinitionVersionId))formDefinitionVersionId= formDefID[1];
 
   
    HtmlFormContext newFormCtx = new HtmlFormContext();
    newFormCtx.setFilePath(filePath+"/"+fileName);
    newFormCtx.setFormDefId(formDefID[0] + "@" + formDefID[1]);
    newFormCtx.setValueMap(valueMap);

   
    if(GlobalContext.logLevelIsDebug && instance!=null){
      instance.addDebugInfo("Form administration url", GlobalContext.WEB_CONTEXT_ROOT + "/processmanager/viewFormDefinition.jsp?objectDefinitionId=" + formDefID[0] + "&processDefinitionVersionID=" + formDefID[1]);
      instance.addDebugInfo("Form data XML path", new File(FILE_SYSTEM_DIR + newFormCtx.getFilePath()).getAbsolutePath());
      instance.addDebugInfo("");
    }
     
    getVariableForHtmlFormContext().set(instance, "", newFormCtx);
   
View Full Code Here

  }
 
  public String getFormDefinitionVersionId(ProcessInstance instance, ProcessManagerRemote pm) throws Exception{
   
    HtmlFormContext formContext = instance==null ? (HtmlFormContext)(getVariableForHtmlFormContext().getDefaultValue()) : (HtmlFormContext)(getVariableForHtmlFormContext().get(instance, ""));
    String formDefId = formContext.getFormDefId();

    return ProcessDefinition.getDefinitionVersionId(pm, formDefId, ProcessDefinition.VERSIONSELECTOPTION_CURRENT_PROD_VER, getProcessDefinition());
  }
View Full Code Here

          setLocate(getLocate()+File.separatorChar+instance.getName());
          File f = new File(getLocate());
          if(f.exists()==false)
            f.mkdir();
         
          HtmlFormContext formContext = (HtmlFormContext)value;
         
          SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSS", Locale.KOREA);
          StringBuffer buff = new StringBuffer();
          buff.append(getLocate());
          buff.append("/");
          buff.append(activity.getName().getText());
          buff.append("_");
          buff.append(sdf.format(new Date()));
          buff.append(".html");
         
          UEngineUtil.copyToFile(fileSystemPath+formContext.getHtmlPath(), buff.toString());
        }
               
      }catch(Exception e){
        e.printStackTrace();
      }finally{
View Full Code Here

      }
     
    }
   
    if(variable.getType() == HtmlFormContext.class){
      HtmlFormContext metaValue = (HtmlFormContext)(variable.getDefaultValue());
     
      if(metaValue.getFormDefId()==null)
        variableNode.add(createRecord("No form template is set", null, isSource));;
     
      String formDefId = ProcessDefinition.splitDefinitionAndVersionId(metaValue.getFormDefId())[0];
      try {
       
        InputStream is = ProcessDesigner.getClientProxy().showFormDefinitionWithDefinitionId(formDefId);
       
        ArrayList formFieldList = (ArrayList) GlobalContext.deserialize(is, ArrayList.class);
        for(int k=0; k<formFieldList.size(); k++){
          Object element = formFieldList.get(k);
          if(element instanceof String){//that means the field parts are started.
            String fieldName = (String)element;
            variableNode.add(createRecord(fieldName, variable.getName() + "." + fieldName, isSource));
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    } 
   
    if(variable.getType() == OfficeDocumentInstance.class){
      OfficeDocumentInstance metaValue = (OfficeDocumentInstance)(variable.getDefaultValue());
     
      if(metaValue.getDocumentDefId()==null)
        variableNode.add(createRecord("No form template is set", null, isSource));;
     
      String formDefId = ProcessDefinition.splitDefinitionAndVersionId(metaValue.getDocumentDefId())[0];
      try {
       
        InputStream is = ProcessDesigner.getClientProxy().showObjectDefinitionWithDefinitionId(formDefId);
       
        OfficeDocumentDefinition odd = (OfficeDocumentDefinition) GlobalContext.deserialize(is, OfficeDocumentDefinition.class);
View Full Code Here

TOP

Related Classes of org.uengine.contexts.HtmlFormContext

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.