Beispiel #1
0
 @RequestMapping(
     value = "/ajax/createNewNosSeries",
     method = RequestMethod.POST,
     params = {"nosSeries"})
 @ResponseBody
 public boolean createNewNosSeries(
     @RequestParam("nosSeries") String nosSeries, HttpServletRequest request) {
   try {
     List<NOSSeries> listNOSSeries = nosSeriesDAO.getAll();
     for (NOSSeries existed : listNOSSeries) {
       String name = existed.getSeriesName();
       if (name.equals(nosSeries)) {
         return false;
       } else {
         NOSSeries newSeries = new NOSSeries();
         newSeries.setSeriesName(nosSeries);
         newSeries.setCategory("");
         newSeries.setDescription("");
         newSeries.setFtpDefaultLocation("");
         newSeries.setNamePattern("");
         newSeries.setOutputDefaultLocation("");
         newSeries.setOutputDefaultNamePattern("");
         newSeries.setStakeholders(null);
         newSeries.setMakeRules(null);
         nosSeriesDAO.add(newSeries);
         return true;
       }
     }
   } catch (Exception e) {
     logger.error("MyNOSSeriesController.createNewNosSeries", e);
   }
   return false;
 }
Beispiel #2
0
  @RequestMapping(
      value = "/ajax/cloneNosSeries",
      method = RequestMethod.POST,
      params = {"nosSeries", "newName"})
  @ResponseBody
  public boolean cloneNosSeries(
      @RequestParam("nosSeries") String nosSeries,
      @RequestParam("newName") String newName,
      HttpServletRequest request) {
    try {
      Principal p = (Principal) request.getSession().getAttribute(Constant.SESSION_KEY_USER);
      if (p == null) {
        return false;
      }
      if (newName == "") {
        return false;
      }
      List<NOSSeries> listNOSSeries = nosSeriesDAO.getAll();
      for (NOSSeries existed : listNOSSeries) {
        String name = existed.getSeriesName();
        if (name.equals(nosSeries)) {
          return false;
        } else {
          NOSSeries newSeries = new NOSSeries();
          NOSSeries currentSeries = nosSeriesDAO.getByName(nosSeries);

          newSeries.setSeriesName(newName);
          String currentCategory = currentSeries.getCategory();
          if (StringUtils.isBlank(currentCategory)) {
            newSeries.setCategory("");
          } else {
            newSeries.setCategory(currentCategory);
          }
          String currentDescript = currentSeries.getDescription();
          if (StringUtils.isBlank(currentDescript)) {
            newSeries.setDescription("");
          } else {
            newSeries.setDescription(currentDescript);
          }
          String ftpDefault = currentSeries.getFtpDefaultLocation();
          if (StringUtils.isBlank(ftpDefault)) {
            newSeries.setFtpDefaultLocation("");
          } else {
            newSeries.setFtpDefaultLocation(ftpDefault);
          }
          String curNosName = currentSeries.getNamePattern();
          if (StringUtils.isBlank(curNosName)) {
            newSeries.setNamePattern("");
          } else {
            newSeries.setNamePattern(curNosName);
          }
          String defaultLocation = currentSeries.getOutputDefaultLocation();
          if (StringUtils.isBlank(defaultLocation)) {
            newSeries.setOutputDefaultLocation("");
          } else {
            newSeries.setOutputDefaultLocation(defaultLocation);
          }
          String curDefaultNos = currentSeries.getOutputDefaultNamePattern();
          if (StringUtils.isBlank(curDefaultNos)) {
            newSeries.setOutputDefaultNamePattern("");
          } else {
            newSeries.setOutputDefaultNamePattern(curDefaultNos);
          }
          String[] curStakehoders = currentSeries.getStakeholders();
          if (curStakehoders.length <= 0) {
            newSeries.setStakeholders(null);
          } else {
            newSeries.setStakeholders(curStakehoders);
          }
          ChangedContent[] curChangeContent = currentSeries.getMakeRules();
          if (curChangeContent.length <= 0) {
            newSeries.setMakeRules(null);
          } else {
            newSeries.setMakeRules(curChangeContent);
          }
          long newSeriesId = nosSeriesDAO.add(newSeries);
          List<SeriesBuildServer> listBuildServer =
              seriesBuildServerDAO.getAllBuildServer(currentSeries.getId());
          List<SeriesBuildServer> newListSBS = new ArrayList<SeriesBuildServer>();
          SeriesBuildServer newSBS = new SeriesBuildServer();
          for (SeriesBuildServer current : listBuildServer) {
            newSBS.setBuildServerId(current.getBuildServerId());
            newSBS.setSeriesId(newSeriesId);
            seriesBuildServerDAO.add(newSBS);
            newListSBS.add(newSBS);
          }
          List<SeriesCapability> listSC = seriesCapabilityDao.getBySeriesId(currentSeries.getId());
          List<SeriesCapability> newListSC = new ArrayList<SeriesCapability>();
          SeriesCapability newSC = new SeriesCapability();
          for (SeriesCapability seriesCapability : listSC) {
            newSC.setContractId(seriesCapability.getContractId());
            newSC.setDeviceId(seriesCapability.getDeviceId());
            newSC.setSeriesId(newSeriesId);
            seriesCapabilityDao.add(newSC);
            newListSC.add(newSC);
          }
          return true;
        }
      }
    } catch (Exception e) {
      logger.warn("MyNOSSeriesController.cloneNosSeries() " + e.getMessage());
    }
    return false;
  }