예제 #1
0
  public List<ItemIndexDTO> toInOutRecordDTO(InventoryCheckDTO inventoryCheckDTO) {
    List<ItemIndexDTO> itemIndexDTOList = new ArrayList<ItemIndexDTO>();

    if (inventoryCheckDTO.getMergeInOutRecordFlag()) {
      if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()) > 0) {
        ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
        itemIndexDTO.setItemType(ItemTypes.OUT);
        itemIndexDTO.setInOutRecordId(this.getId());
        itemIndexDTO.setItemCount(
            NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount()));
        itemIndexDTO.setUnit(this.getSellUnit());
        itemIndexDTOList.add(itemIndexDTO);
      } else if (NumberUtil.subtraction(this.getInventoryAmount(), this.getActualInventoryAmount())
          < 0) {
        ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
        itemIndexDTO.setItemType(ItemTypes.IN);
        itemIndexDTO.setInOutRecordId(this.getId());
        itemIndexDTO.setItemCount(
            NumberUtil.round(this.getActualInventoryAmount() - this.getInventoryAmount(), 1));
        itemIndexDTO.setUnit(this.getSellUnit());
        itemIndexDTOList.add(itemIndexDTO);
      }
    } else {
      if (!ArrayUtils.isEmpty(this.getOutStorageRelationDTOs())) {
        for (OutStorageRelationDTO outStorageRelationDTO : getOutStorageRelationDTOs()) {
          ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
          itemIndexDTO.setItemType(ItemTypes.OUT);
          itemIndexDTO.setInOutRecordId(outStorageRelationDTO.getId());
          itemIndexDTO.setRelatedSupplierId(outStorageRelationDTO.getRelatedSupplierId());
          itemIndexDTO.setRelatedSupplierName(outStorageRelationDTO.getRelatedSupplierName());
          itemIndexDTO.setItemCount(outStorageRelationDTO.getSupplierRelatedAmount());
          itemIndexDTO.setUnit(outStorageRelationDTO.getOutStorageUnit());
          itemIndexDTOList.add(itemIndexDTO);
        }
      }
      if (!ArrayUtils.isEmpty(this.getInStorageRecordDTOs())) {
        for (InStorageRecordDTO inStorageRecordDTO : getInStorageRecordDTOs()) {
          ItemIndexDTO itemIndexDTO = toItemIndexDTO(inventoryCheckDTO);
          itemIndexDTO.setItemType(ItemTypes.IN);
          itemIndexDTO.setInOutRecordId(inStorageRecordDTO.getId());
          itemIndexDTO.setRelatedSupplierId(inStorageRecordDTO.getSupplierId());
          itemIndexDTO.setRelatedSupplierName(inStorageRecordDTO.getSupplierName());
          itemIndexDTO.setItemCount(inStorageRecordDTO.getSupplierRelatedAmount());
          itemIndexDTO.setUnit(inStorageRecordDTO.getInStorageUnit());
          itemIndexDTOList.add(itemIndexDTO);
        }
      }
    }

    return itemIndexDTOList;
  }
예제 #2
0
  public String createReportConfig() {
    S_LOGGER.debug("Entering Method  SiteReport.createReportConfig()");

    try {
      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      ProjectInfo projectInfo = administrator.getProject(projectCode).getProjectInfo();

      // To get the selected reports from the UI
      String[] arraySelectedReports = getHttpRequest().getParameterValues(REQ_SITE_REPORTS);
      List<String> selectedReports = null;
      if (!ArrayUtils.isEmpty(arraySelectedReports)) {
        selectedReports = Arrays.asList(arraySelectedReports);
      }

      // To get the selected ReportCategories from the UI
      String[] arraySelectedRptCategories =
          getHttpRequest().getParameterValues(REQ_SITE_SLECTD_REPORTSCATEGORIES);
      List<ReportCategories> selectedReportCategories = new ArrayList<ReportCategories>();
      if (!ArrayUtils.isEmpty(arraySelectedRptCategories)) {
        for (String arraySelectedRptCategory : arraySelectedRptCategories) {
          ReportCategories cat = new ReportCategories();
          cat.setName(arraySelectedRptCategory);
          selectedReportCategories.add(cat);
        }
      }

      // To get the list of Reports to be added
      List<Reports> allReports = administrator.getReports(projectInfo);
      List<Reports> reportsToBeAdded = new ArrayList<Reports>();
      if (CollectionUtils.isNotEmpty(selectedReports) && CollectionUtils.isNotEmpty(allReports)) {
        for (Reports report : allReports) {
          if (selectedReports.contains(report.getArtifactId())) {
            reportsToBeAdded.add(report);
          }
        }
      }

      administrator.updateRptPluginInPOM(projectInfo, reportsToBeAdded, selectedReportCategories);
      addActionMessage(getText(SUCCESS_SITE_CONFIGURE));
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of SiteReport.createReportConfig()"
              + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "Configuring site report");
    }

    return viewSiteReport();
  }
예제 #3
0
  @Override
  public void prepare() {
    if (id != null) overhead = overheadService.findById(id, false);

    // expenditureTypeList = (List) overheadService.findAllBy("select distinct expenditureType from
    // WorkType");
    expenditureTypeList =
        (List) overheadService.findAllBy("select distinct expenditureType from Overhead");
    super.prepare();
    setupDropdownDataExcluding("account");
    try {
      List<CChartOfAccounts> accounts = new ArrayList<CChartOfAccounts>();
      // TODO:
      if (worksService.getWorksConfigValue("OVERHEAD_PURPOSE") != null)
        accounts =
            commonsService.getAccountCodeByPurpose(
                Integer.valueOf(worksService.getWorksConfigValue("OVERHEAD_PURPOSE")));
      addDropdownData("accountList", accounts);
    } catch (final ApplicationException e) {
      logger.error("Unable to load accountcode :" + e.getMessage());
      addFieldError("accountcode", "Unable to load accountcode");
    }

    final String[] expenditure = parameters.get("expenditure");
    if (!ArrayUtils.isEmpty(expenditure) && !expenditure[0].equals("-1"))
      overhead.setExpenditureType(new ExpenditureType(expenditure[0]));
  }
예제 #4
0
 public static void setProperties(String[] jvmParameters) throws IndexOutOfBoundsException {
   if (ArrayUtils.isEmpty(jvmParameters)) return;
   for (String jp : jvmParameters) {
     String[] keyAndValue = jp.split("=");
     System.setProperty(keyAndValue[0], keyAndValue[1]);
   }
 }
예제 #5
0
 public void onDataLoad(DataLoadEvent se) {
   Dataset ds = se.getSource();
   String keys = ds.getReqParameters().getParameterValue("query_param_keys");
   String values = null;
   if (keys != null && !keys.equals("")) {
     values = ds.getReqParameters().getParameterValue("query_param_values");
   }
   int userType = 0;
   CpMenuItemVO[] menuitems = null;
   ICpMenuQry service = CpbServiceFacility.getMenuQry();
   try {
     menuitems = service.getMenuItemsByCategory(values);
     if (userType == 2 /* CpUserVO.USERTYPE_SYSADMIN */) {
       // menuitems = service.getMenuItemsByCategory(values);
     } else if (userType == 3 /* CpUserVO.USERTYPE_GROUPADMIN */) {
       // appsNodes =
       // CpbServiceFacility.getFunQryService().getNodeByUser(values,
       // userVo.getCuserid(), "");
     }
   } catch (CpbBusinessException e) {
     // TODO Auto-generated catch block
     LfwLogger.error(e.getMessage(), e);
     throw new LfwRuntimeException(e.getMessage());
   }
   if (ArrayUtils.isEmpty(menuitems)) {
     return;
   }
   new SuperVO2DatasetSerializer().serialize(menuitems, ds, Row.STATE_NORMAL);
   postProcessRowSelect(ds);
 }
  private static String[] addRoutePrefix(String[] routes, String routePrefix) {
    if (ArrayUtils.isEmpty(routes)) return routes;

    if (StringUtils.isEmpty(routePrefix)) return routes;

    String[] r = new String[routes.length];
    for (int i = 0; i < r.length; i++) r[i] = routePrefix + routes[i];
    return r;
  }
예제 #7
0
 /**
  * 根据断电告警派单编号删除断电告警派单信息
  *
  * @param id String[] 断电告警派单编号数组
  */
 @Override
 public void deleteOeDispatchTask(String[] id) {
   if (ArrayUtils.isEmpty(id)) {
     return;
   }
   for (int i = 0; i < id.length; i++) {
     oeDispatchTaskDao.delete(id[i]);
   }
 }
예제 #8
0
  /**
   * @param cacheNames 2 Optional caches names.
   * @return 2 preconfigured meta caches.
   */
  private GridCacheConfiguration[] metaCaches(String... cacheNames) {
    assertTrue(ArrayUtils.isEmpty(cacheNames) || cacheNames.length == 2);

    if (ArrayUtils.isEmpty(cacheNames)) cacheNames = new String[] {metaCache1Name, metaCache2Name};

    GridCacheConfiguration[] res = new GridCacheConfiguration[cacheNames.length];

    for (int i = 0; i < cacheNames.length; i++) {
      GridCacheConfiguration metaCache = defaultCacheConfiguration();

      metaCache.setName(cacheNames[i]);
      metaCache.setAtomicityMode(TRANSACTIONAL);
      metaCache.setQueryIndexEnabled(false);

      res[i] = metaCache;
    }

    return res;
  }
예제 #9
0
 /**
  * Verifies whether array of the repository Urls is empty.
  *
  * @param urls repository Urls.
  * @return true if array is empty.
  */
 public static boolean isEmpty(String[] urls) {
   if (ArrayUtils.isEmpty(urls)) {
     return true;
   }
   for (String url : urls) {
     if (StringUtils.isNotEmpty(url)) {
       return false;
     }
   }
   return true;
 }
 private void removeRandomPasswords(IdentityProvider identityProvider) {
   for (ProvisioningConnectorConfig provisioningConnectorConfig :
       identityProvider.getProvisioningConnectorConfigs()) {
     Property[] properties = provisioningConnectorConfig.getProvisioningProperties();
     if (ArrayUtils.isEmpty(properties)) {
       continue;
     }
     properties = RandomPasswordProcessor.getInstance().removeRandomPasswords(properties);
     provisioningConnectorConfig.setProvisioningProperties(properties);
   }
 }
예제 #11
0
  /**
   * @param grpSize Group size to use in {@link GridGgfsGroupDataBlocksKeyMapper}.
   * @param cacheNames 2 Optional caches names.
   * @return 2 preconfigured data caches.
   */
  private GridCacheConfiguration[] dataCaches(int grpSize, String... cacheNames) {
    assertTrue(ArrayUtils.isEmpty(cacheNames) || cacheNames.length == 2);

    if (ArrayUtils.isEmpty(cacheNames)) cacheNames = new String[] {dataCache1Name, dataCache2Name};

    GridCacheConfiguration[] res = new GridCacheConfiguration[cacheNames.length];

    for (int i = 0; i < cacheNames.length; i++) {
      GridCacheConfiguration dataCache = defaultCacheConfiguration();

      dataCache.setName(cacheNames[i]);
      dataCache.setAffinityMapper(new GridGgfsGroupDataBlocksKeyMapper(grpSize));
      dataCache.setAtomicityMode(TRANSACTIONAL);
      dataCache.setQueryIndexEnabled(false);

      res[i] = dataCache;
    }

    return res;
  }
예제 #12
0
 /** remove article list */
 private void removeArticleList() {
   try {
     if (!ArrayUtils.isEmpty(listToDelete)) {
       String[] deletedList = adminService.deleteArticleList(getCurrentJournal(), listToDelete);
       addActionMessage(
           "Successfully removed the following article list: " + Arrays.toString(deletedList));
     }
   } catch (Exception e) {
     log.error("Error deleting article list: " + Arrays.toString(listToDelete), e);
     addActionError("Article List remove failed due to the following error: " + e.getMessage());
   }
   repopulate();
 }
예제 #13
0
 private void checkExeuctionErrors(ProcessReports[] processReports) {
   if (samplingCount == 0
       && ArrayUtils.isNotEmpty(this.processReports)
       && ArrayUtils.isEmpty(processReports)) {
     getListeners()
         .apply(
             new Informer<ConsoleShutdownListener>() {
               public void inform(ConsoleShutdownListener listener) {
                 listener.readyToStop(StopReason.SCRIPT_ERROR);
               }
             });
   }
 }
예제 #14
0
  /**
   * @param words
   * @param separator
   * @return String of words concatonated with the separator
   */
  public static String join(double[] words, String separator) {

    if (ArrayUtils.isEmpty(words)) return EMPTY;

    StringBuilder ret = new StringBuilder();
    for (int i = 0; i < words.length; i++) {
      if (i > 0) {
        ret.append(separator);
      }
      ret.append(words[i]);
    }
    return ret.toString();
  }
  /** Binds parameters using indices..parameter names are ignored */
  public void bind(Query query, String[] paramNames, Object[] paramValues) {

    if (!ArrayUtils.isEmpty(paramValues)) {
      for (int j = 0; j < paramValues.length; j++) {
        if (paramValues[j] instanceof java.sql.Date)
          query.setParameter(j, (java.sql.Date) paramValues[j], TemporalType.DATE);
        else if (paramValues[j] instanceof java.sql.Time)
          query.setParameter(j, (java.sql.Time) paramValues[j], TemporalType.TIME);
        else if (paramValues[j] instanceof java.sql.Timestamp)
          query.setParameter(j, (java.sql.Timestamp) paramValues[j], TemporalType.TIMESTAMP);
        else query.setParameter(j, paramValues[j]);
      }
    }
  }
예제 #16
0
파일: Parser.java 프로젝트: kaliy/bfgex
  private static Sexp union(Sexp lhs, Sexp... rhs) {
    if (lhs == null) {
      return union(rhs[0], (Sexp[]) ArrayUtils.remove(rhs, 0));
    } else if (ArrayUtils.isEmpty(rhs)) {
      return lhs;
    } else if (lhs.first() != null && lhs.first().equals(UNION)) {
      for (Sexp sexp : rhs) {
        lhs.add(sexp);
      }
      return lhs;
    }

    return new Sexp(UNION).add(lhs).addAll(rhs);
  }
 protected boolean canHandleAnnotationOverride(
     OverrideViaAnnotationRequest overrideViaAnnotationRequest,
     Map<String, FieldMetadata> metadata) {
   AdminPresentationOverrides myOverrides =
       overrideViaAnnotationRequest
           .getRequestedEntity()
           .getAnnotation(AdminPresentationOverrides.class);
   AdminPresentationMergeOverrides myMergeOverrides =
       overrideViaAnnotationRequest
           .getRequestedEntity()
           .getAnnotation(AdminPresentationMergeOverrides.class);
   return (myOverrides != null && !ArrayUtils.isEmpty(myOverrides.adornedTargetCollections()))
       || myMergeOverrides != null;
 }
예제 #18
0
  public static void main(String[] args) {
    TestDataLoader testDataLoader = new TestDataLoader();
    Date groupCreationDate = new Date(0);

    if (ArrayUtils.isEmpty(args) || args.length < 2) {
      System.out.println("The program requires at least two arguments.");
      return;
    }

    if (!StringUtils.isAlphanumeric(args[0])) {
      System.out.println("The first argument should be a number.");
      return;
    }

    for (int numOfRound = Integer.parseInt(args[0]); numOfRound > 0; numOfRound--) {
      if (ArrayUtils.contains(args, "poster")) {
        OriginEntryGroup group = new OriginEntryGroup();
        group.setSourceCode(LABOR_SCRUBBER_VALID);
        group.setValid(true);
        group.setScrub(false);
        group.setProcess(true);
        group.setDate(groupCreationDate);
        int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group);
        System.out.println("Number of Origin Entries for Poster = " + numOfData);
      }

      if (ArrayUtils.contains(args, "scrubber")) {
        OriginEntryGroup group = new OriginEntryGroup();
        group.setSourceCode(LABOR_BACKUP);
        group.setValid(true);
        group.setScrub(true);
        group.setProcess(true);
        group.setDate(groupCreationDate);
        int numOfData = testDataLoader.loadTransactionIntoOriginEntryTable(group);
        System.out.println("Number of Origin Entries for Scrubber = " + numOfData);
      }

      if (ArrayUtils.contains(args, "pending")) {
        int numOfData = testDataLoader.loadTransactionIntoPendingEntryTable();
        System.out.println("Number of Pending Entries = " + numOfData);
      }

      if (ArrayUtils.contains(args, "glentry")) {
        int numOfData = testDataLoader.loadTransactionIntoGLEntryTable();
        System.out.println("Number of Labor GL Entries = " + numOfData);
      }
    }
    System.exit(0);
  }
예제 #19
0
 /*
  * In the user consent filter the scopes are (possible) set on the Request
  */
 private void processScopes(AuthorizationRequest authReq, HttpServletRequest request) {
   if (authReq.getClient().isSkipConsent()) {
     // return the scopes in the authentication request since the requested scopes are stored in
     // the
     // authorizationRequest.
     authReq.setGrantedScopes(authReq.getRequestedScopes());
   } else {
     String[] scopes = (String[]) request.getAttribute(AbstractUserConsentHandler.GRANTED_SCOPES);
     if (!ArrayUtils.isEmpty(scopes)) {
       authReq.setGrantedScopes(Arrays.asList(scopes));
     } else {
       authReq.setGrantedScopes(null);
     }
   }
 }
예제 #20
0
  public boolean destroyComments(final Context ctx, final long... commentIds) {
    if (ArrayUtils.isEmpty(commentIds)) return true;

    final long now = DateHelper.nowMillis();
    final ShardResult commentSR = shardComment();
    return sqlExecutor.openConnection(
        commentSR.db,
        new SingleConnectionHandler<Boolean>() {
          @Override
          protected Boolean handleConnection(Connection conn) {
            String sql = CommentSql.disableComments(ctx, commentSR.table, now, commentIds);
            long n = SqlExecutor.executeUpdate(ctx, conn, sql);
            return n > 0;
          }
        });
  }
예제 #21
0
 @Override
 public List<ProductCategoryRelationDTO> productCategoryRelationDTOQuery(
     Long shopId, Long... productLocalInfoIds) {
   List<ProductCategoryRelationDTO> result = new ArrayList<ProductCategoryRelationDTO>();
   if (ArrayUtils.isEmpty(productLocalInfoIds) || shopId == null) {
     return result;
   }
   ProductWriter productWriter = productDaoManager.getWriter();
   List<ProductCategoryRelation> productCategoryRelations =
       productWriter.getProductCategoryRelations(shopId, productLocalInfoIds);
   if (CollectionUtils.isNotEmpty(productCategoryRelations)) {
     for (ProductCategoryRelation productCategoryRelation : productCategoryRelations) {
       result.add(productCategoryRelation.toDTO());
     }
   }
   return result;
 }
예제 #22
0
  @Override
  public void contextInitialized(final ServletContextEvent event) {
    // we first remove the default handler(s)
    final Logger rootLogger = LogManager.getLogManager().getLogger("");
    final Handler[] handlers = rootLogger.getHandlers();

    if (!ArrayUtils.isEmpty(handlers)) {
      for (final Handler handler : handlers) {
        rootLogger.removeHandler(handler);
      }
    }
    // and then we let jul-to-sfl4j do its magic so that jersey messages go to sfl4j (and thus
    // log4j)
    SLF4JBridgeHandler.install();

    log.info("Assimilated java.util Logging");
  }
예제 #23
0
  public static void bootUsingSpring(
      String systemFlag, String[] contextFilePathes, String[] systemParameters) {
    Preconditions.checkArgument(StringUtils.isNotBlank(systemFlag), "systemFlag is blank.");
    Preconditions.checkArgument(
        (!ArrayUtils.isEmpty(contextFilePathes)) && (contextFilePathes.length > 0),
        "contextFilePathes is empty.");

    long beginMTime = System.currentTimeMillis();
    setProperties(systemParameters);
    try {
      new ClassPathXmlApplicationContext(contextFilePathes);
      LOGGER.info(systemFlag + " boot in " + (System.currentTimeMillis() - beginMTime) + " ms");

    } catch (Exception e) {
      LOGGER.error(systemFlag + " boot occur error:", e);
      System.exit(-1);
    }
  }
  @Override
  public void update(String viewPath, String[] loadRules) throws IOException, InterruptedException {
    FilePath filePath = getLauncher().getWorkspace().child(viewPath);
    ArgumentListBuilder cmd = new ArgumentListBuilder();
    cmd.add("update");
    cmd.add("-force");
    cmd.add("-overwrite");
    cmd.add("-log", "NUL");
    if (!ArrayUtils.isEmpty(loadRules)) {
      cmd.add("-add_loadrules");
      for (String loadRule : loadRules) {
        cmd.add(fixLoadRule(loadRule));
      }
    }

    runAndProcessOutput(
        cmd, new ByteArrayInputStream("yes\nyes\n".getBytes()), filePath, false, null);
  }
예제 #25
0
  public static String md5(final char[] input, final String salt) {

    if (ArrayUtils.isEmpty(input)) {
      throw new IllegalArgumentException("Input can not be null");
    }

    String inputToBeConverted = new String(input) + StringUtils.trimToEmpty(salt);

    String md5 = null;
    if (null == input) return null;
    try {
      MessageDigest digest = MessageDigest.getInstance("MD5");
      digest.update(inputToBeConverted.getBytes(), 0, inputToBeConverted.length());
      md5 = new BigInteger(1, digest.digest()).toString(16);
    } catch (NoSuchAlgorithmException e) {
      throw new UnsupportedOperationException("Algorithm does not exist", e);
    }
    return md5;
  }
예제 #26
0
 public static void main(String args[]) {
   // INFO: Unter MacOsx muss jar wie folgt gestartet werden: java
   // -XstartOnFirstThread -jar
   try {
     if (!ArrayUtils.isEmpty(args) && !args[0].equals("-debug")) {
       BeeLogger.removeConsoleHandler();
     }
     logger.info("xdccBee start");
     window = new Application();
     window.setBlockOnOpen(true);
     window.open();
     if (Display.getCurrent() != null && !Display.getCurrent().isDisposed()) {
       Display.getCurrent().dispose();
     }
   } catch (Exception e) {
     BeeLogger.exception(e);
     throw new RuntimeException(e);
   }
   System.exit(0);
 }
예제 #27
0
 /**
  * 指定日期下handler列表
  *
  * @param monitorTime
  * @return
  */
 public static HashSet<String> queryMonitorHandler(Date monitorTime) {
   HashSet<String> result = new HashSet<String>();
   File dirA =
       new File(DATA_DIR, getDateFormat(FormatPath_yyyyMM).format(monitorTime)); // ../201509
   if (dirA.exists() && dirA.isDirectory()) {
     File dirB = new File(dirA, FormatPath_dd.format(monitorTime)); // ../201509/01
     if (dirB.exists() && dirB.isDirectory()) {
       File[] fileArray = dirB.listFiles();
       if (!ArrayUtils.isEmpty(fileArray)) {
         for (File file : fileArray) {
           if (file.getName().indexOf("_") != -1) {
             result.add(file.getName().substring(0, file.getName().indexOf("_")));
           }
         }
         if (CollectionUtils.isNotEmpty(result)) {
           return result;
         }
       }
     }
   }
   return result;
 }
예제 #28
0
 /**
  * 加载文件list
  *
  * @param handlerName specify monitor handle file name
  * @param monitorTime specify monitor date
  * @return
  */
 private static List<File> queryFiles(String handlerName, Date monitorTime) {
   File dirA =
       new File(DATA_DIR, getDateFormat(FormatPath_yyyyMM).format(monitorTime)); // ../201509
   if (dirA.exists() && dirA.isDirectory()) {
     File dirB = new File(dirA, FormatPath_dd.format(monitorTime)); // ../201509/01
     if (dirB.exists() && dirB.isDirectory()) {
       File[] fileArray = dirB.listFiles();
       if (!ArrayUtils.isEmpty(fileArray)) {
         List<File> result = new ArrayList<File>();
         for (File file : fileArray) {
           if (file.getName().startsWith(handlerName + "_")) {
             result.add(file);
           }
         }
         if (CollectionUtils.isNotEmpty(result)) {
           return result;
         }
       }
     }
   }
   return null;
 }
예제 #29
0
파일: CI.java 프로젝트: ab-k/phresco
  public String configure() {
    S_LOGGER.debug("Entering Method  CI.configure()");
    try {
      String[] selectedJobsName = getHttpRequest().getParameterValues(REQ_SELECTED_JOBS_LIST);
      String jobName = "";
      if (!ArrayUtils.isEmpty(selectedJobsName)) {
        jobName = selectedJobsName[0];
      }
      S_LOGGER.debug("selectedJobs for configuration " + jobName);

      ProjectAdministrator administrator = PhrescoFrameworkFactory.getProjectAdministrator();
      Project project = administrator.getProject(projectCode);
      // Get environment info
      List<Environment> environments = administrator.getEnvironments(project);
      getHttpRequest().setAttribute(REQ_ENVIRONMENTS, environments);
      getHttpRequest().setAttribute(REQ_PROJECT, project);
      // Get xcode targets
      String technology = project.getProjectInfo().getTechnology().getId();
      if (TechnologyTypes.IPHONES.contains(technology)) {
        List<PBXNativeTarget> xcodeConfigs = ApplicationsUtil.getXcodeConfiguration(projectCode);
        getHttpRequest().setAttribute(REQ_XCODE_CONFIGS, xcodeConfigs);
        // get list of sdks
        List<String> iphoneSdks = IosSdkUtil.getMacSdks(MacSdkType.iphoneos);
        iphoneSdks.addAll(IosSdkUtil.getMacSdks(MacSdkType.iphonesimulator));
        iphoneSdks.addAll(IosSdkUtil.getMacSdks(MacSdkType.macosx));
        getHttpRequest().setAttribute(REQ_IPHONE_SDKS, iphoneSdks);
      }
      CIJob existJob = administrator.getJob(project, jobName);
      existJob.setCollabNetpassword(CIPasswordScrambler.unmask(existJob.getCollabNetpassword()));
      getHttpRequest().setAttribute(REQ_EXISTING_JOB, existJob);
      getHttpRequest().setAttribute(REQ_SELECTED_MENU, APPLICATIONS);
      getHttpRequest().setAttribute(REQ_PROJECT_CODE, projectCode);
    } catch (Exception e) {
      S_LOGGER.error(
          "Entered into catch block of CI.configure()" + FrameworkUtil.getStackTraceAsString(e));
      new LogErrorReport(e, "CI configuration clicked");
    }
    return APP_CI_CONFIGURE;
  }
  /**
   * compiles jars from files in the shell virtual directory on the fly, sends and executes it in
   * the remote environment
   *
   * @param jobName name of the job as string
   * @return Result of the computation
   * @throws Exception
   */
  @Override
  public JobExecutionResult execute(String jobName) throws Exception {
    Plan p = createProgramPlan(jobName);

    String jarFile = flinkILoop.writeFilesToDisk().getAbsolutePath();

    // get "external jars, and add the shell command jar, pass to executor
    List<String> alljars = new ArrayList<String>();
    // get external (library) jars
    String[] extJars = this.flinkILoop.getExternalJars();

    if (!ArrayUtils.isEmpty(extJars)) {
      alljars.addAll(Arrays.asList(extJars));
    }
    // add shell commands
    alljars.add(jarFile);
    String[] alljarsArr = new String[alljars.size()];
    alljarsArr = alljars.toArray(alljarsArr);
    PlanExecutor executor = PlanExecutor.createRemoteExecutor(host, port, alljarsArr);

    executor.setPrintStatusDuringExecution(p.getExecutionConfig().isSysoutLoggingEnabled());
    return executor.executePlan(p);
  }