/**
   * 領域マスタの1レコードをMap形式で返す。 引数には主キー値を渡す。
   *
   * @param connection
   * @param labelKubun
   * @param value
   * @return
   * @throws NoDataFoundException
   * @throws DataAccessException
   */
  public static Map selectRecord(Connection connection, String ryouikiNo)
      throws NoDataFoundException, DataAccessException {
    // -----------------------
    // SQL文の作成
    // -----------------------
    String select =
        "SELECT"
            + " A.RYOIKI_NO"
            + ",A.RYOIKI_RYAKU"
            + ",A.KOMOKU_NO"
            // 2006/06/26 苗 修正ここから
            + ",A.SETTEI_KIKAN" // 設定期間
            + ",A.SETTEI_KIKAN_KAISHI" // 設定期間(開始年度)
            + ",A.SETTEI_KIKAN_SHURYO" // 設定期間(終了年度)
            // 2006/06/26 苗 修正ここまで
            + ",A.BIKO"
            + " FROM MASTER_RYOIKI A"
            + " WHERE RYOIKI_NO = ? ";

    if (log.isDebugEnabled()) {
      log.debug("query:" + select);
    }

    // -----------------------
    // レコード取得
    // -----------------------
    List result = SelectUtil.select(connection, select, new String[] {ryouikiNo});
    if (result.isEmpty()) {
      throw new NoDataFoundException("当該レコードは存在しません。領域No=" + ryouikiNo);
    }
    return (Map) result.get(0);
  }
  private int[] getSelectedRows(int[] selectedRowsNumber, Map[] selectedRowsKeys, Tab tab) {
    if (selectedRowsKeys == null || selectedRowsKeys.length == 0) return new int[0];
    // selectedRowsNumber is the most performant so we use it when possible
    else if (selectedRowsNumber.length == selectedRowsKeys.length) return selectedRowsNumber;
    else {
      // find the rows from the selectedKeys

      // This has a poor performance, but it covers the case when the selected
      // rows are not loaded for the tab, something that can occurs if the user
      // select rows and afterwards reorder the list.
      try {
        int[] s = new int[selectedRowsKeys.length];
        List selectedKeys = Arrays.asList(selectedRowsKeys);
        int end = tab.getTableModel().getTotalSize();
        int x = 0;
        for (int i = 0; i < end; i++) {
          Map key = (Map) tab.getTableModel().getObjectAt(i);
          if (selectedKeys.contains(key)) {
            s[x] = i;
            x++;
          }
        }
        return s;
      } catch (Exception ex) {
        log.warn(XavaResources.getString("fails_selected"), ex);
        throw new XavaException("fails_selected");
      }
    }
  }
示例#3
0
 public void movePropertyToRight(int index) {
   if (propertiesNames == null) return;
   if (index >= propertiesNames.size() - 1) return;
   Object aux = propertiesNames.get(index);
   propertiesNames.set(index, propertiesNames.get(index + 1));
   propertiesNames.set(index + 1, aux);
   resetAfterAddRemoveProperty();
 }
示例#4
0
 public void movePropertyToLeft(int index) {
   if (propertiesNames == null) return;
   if (index <= 0) return;
   Object aux = propertiesNames.get(index);
   propertiesNames.set(index, propertiesNames.get(index - 1));
   propertiesNames.set(index - 1, aux);
   resetAfterAddRemoveProperty();
 }
示例#5
0
 public List<String> getPropertiesNamesWithKeyAndHidden() throws XavaException {
   if (propertiesNamesWithKeyAndHidden == null) {
     propertiesNamesWithKeyAndHidden = new ArrayList<String>();
     propertiesNamesWithKeyAndHidden.addAll(getMetaModel().getAllKeyPropertiesNames());
     propertiesNamesWithKeyAndHidden.addAll(getPropertiesNames());
     propertiesNamesWithKeyAndHidden.addAll(getHiddenPropertiesNames());
   }
   return propertiesNamesWithKeyAndHidden;
 }
示例#6
0
  public Stock getStockByItem(int itemid) { // 用 商品編號 查出 該商品所在的某一貨架
    Query query =
        XPersistence.getManager()
            .createQuery(
                "FROM Stock o WHERE o.item.oid = :itemid order by o.volume desc"); // JPQL query
    query.setParameter("itemid", itemid);

    List<Stock> beans = query.getResultList();
    logger.debug("OrderPlaceDDAO.getStockByItem beans: " + beans);

    return beans.get(0);
  }
  private void handleSignupPost(Request request, HttpServletResponse httpServletResponse)
      throws Exception {
    String userId = request.getParameter(PARAM_USER_ID);
    String userName = request.getParameter(PARAM_USER_NAME);
    String email = request.getParameter(PARAM_EMAIL);
    String stringPassword = request.getParameter(PARAM_PASSWORD);
    String stringPasswordConfirm = request.getParameter(PARAM_PASSWORD_CONFIRM);

    if (!stringPassword.equals(stringPasswordConfirm)) {
      WebUtils.redirectToError(
          "Mismatch between password and password confirmation", request, httpServletResponse);
      return;
    }

    SecureRandom secureRandom = new SecureRandom();
    String salt = "" + secureRandom.nextLong();
    byte[] password = User.computeHashedPassword(stringPassword, salt);
    User user = userDb.get(userId);
    if (user != null) {
      WebUtils.redirectToError(
          "There already exists a user with the ID " + userId, request, httpServletResponse);
      return;
    }

    user =
        new User(
            userId,
            userName,
            password,
            salt,
            email,
            new ArrayList<String>(),
            Config.getConfig().activateAccountsAtCreation,
            false);
    // ttt2 add confirmation by email, captcha, ...
    List<String> fieldErrors = user.checkFields();
    if (!fieldErrors.isEmpty()) {
      StringBuilder bld =
          new StringBuilder("Invalid values when trying to create user with ID ")
              .append(userId)
              .append("<br/>");
      for (String s : fieldErrors) {
        bld.append(s).append("<br/>");
      }
      WebUtils.redirectToError(bld.toString(), request, httpServletResponse);
      return;
    }

    // ttt2 2 clients can add the same userId simultaneously
    userDb.add(user);

    httpServletResponse.sendRedirect("/");
  }
示例#8
0
 // assert(!areAllProperties());
 private List createPropertiesNames() {
   StringTokenizer st = new StringTokenizer(removeTotalProperties(properties), ",;");
   List result = new ArrayList();
   while (st.hasMoreTokens()) {
     String name = st.nextToken().trim();
     if (name.endsWith("+")) {
       name = name.substring(0, name.length() - 1);
       if (sumPropertiesNames == null) sumPropertiesNames = new HashSet();
       sumPropertiesNames.add(name);
     }
     result.add(name);
   }
   return result;
 }
 private boolean calculateWithValidValues() {
   Iterator it = metaProperties.iterator();
   while (it.hasNext()) {
     MetaProperty m = (MetaProperty) it.next();
     if (m.hasValidValues()) return true;
   }
   return false;
 }
示例#10
0
 public List namesToMetaProperties(Collection names) throws XavaException {
   List metaProperties = new ArrayList();
   Iterator it = names.iterator();
   int i = -1;
   while (it.hasNext()) {
     i++;
     String name = (String) it.next();
     MetaProperty metaPropertyTab = null;
     try {
       MetaProperty metaProperty = getMetaModel().getMetaProperty(name).cloneMetaProperty();
       metaProperty.setQualifiedName(name);
       String labelId = null;
       if (representCollection()) {
         labelId = getId() + "." + name;
         // If there is no specific translation for the collection,
         // we take the translation from the default tab.
         if (!Labels.existsExact(labelId)) {
           labelId = getIdForDefaultTab() + ".properties." + name;
         }
       } else {
         labelId = getId() + ".properties." + name;
       }
       if (Labels.exists(labelId)) {
         metaProperty.setLabelId(labelId);
       } else if (metaPropertiesTab != null) {
         // By now only the label overwritten from the property of tab
         metaPropertyTab = (MetaProperty) metaPropertiesTab.get(name);
         if (metaPropertyTab != null) {
           metaProperty = metaProperty.cloneMetaProperty();
           metaProperty.setLabel(metaPropertyTab.getLabel());
         }
       }
       metaProperties.add(metaProperty);
     } catch (ElementNotFoundException ex) {
       MetaProperty notInEntity = new MetaProperty();
       notInEntity.setName(name);
       notInEntity.setTypeName("java.lang.Object");
       if (metaPropertyTab != null) {
         notInEntity.setLabel(metaPropertyTab.getLabel());
       }
       metaProperties.add(notInEntity);
     }
   }
   return metaProperties;
 }
  /**
   * 領域マスタの1レコードをMap形式で返す。 引数には主キー値を渡す。
   *
   * @param connection
   * @param labelKubun
   * @param value
   * @return
   * @throws NoDataFoundException
   * @throws DataAccessException
   */
  public static Map selectRecord(Connection connection, RyouikiInfoPk pkInfo, String ryoikiKbn)
      throws NoDataFoundException, DataAccessException {
    // -----------------------
    // SQL文の作成
    // -----------------------
    String select =
        "SELECT"
            + " A.RYOIKI_NO"
            + ",A.RYOIKI_RYAKU"
            + ",A.KOMOKU_NO"
            // 2006/07/04 苗 修正ここから
            + ",A.SETTEI_KIKAN" // 設定期間
            + ",A.SETTEI_KIKAN_KAISHI" // 設定期間(開始年度)
            + ",A.SETTEI_KIKAN_SHURYO" // 設定期間(終了年度)
            // 2006/07/04 苗 修正ここまで
            + " FROM MASTER_RYOIKI A"
            + " WHERE RYOIKI_NO = ? "
            + " AND KOMOKU_NO = ? ";

    // 計画研究の場合
    if ("1".equals(ryoikiKbn)) {
      select = select + " AND KEIKAKU_FLG = '1'";
    }
    // 公募研究の場合
    else if ("2".equals(ryoikiKbn)) {
      select = select + " AND KOUBO_FLG = '1'";
    }

    if (log.isDebugEnabled()) {
      log.debug("query:" + select);
    }

    // -----------------------
    // レコード取得
    // -----------------------
    List result =
        SelectUtil.select(
            connection, select, new String[] {pkInfo.getRyoikiNo(), pkInfo.getKomokuNo()});
    if (result.isEmpty()) {
      throw new NoDataFoundException("当該レコードは存在しません。");
    }
    return (Map) result.get(0);
  }
示例#12
0
 private List createAllPropertiesNames() throws XavaException {
   List result = new ArrayList();
   // First the properties from a possible @EmbeddedId
   for (Iterator itRef = getMetaModel().getMetaReferencesKey().iterator(); itRef.hasNext(); ) {
     MetaReference ref = (MetaReference) itRef.next();
     if (ref.isAggregate()) {
       for (Iterator itKey =
               ref.getMetaModelReferenced()
                   .getPropertiesNamesWithoutHiddenNorTransient()
                   .iterator();
           itKey.hasNext(); ) {
         result.add(ref.getName() + "." + itKey.next());
       }
     }
   }
   // Now the plain properties
   result.addAll(getMetaModel().getPropertiesNamesWithoutHiddenNorTransient());
   return result;
 }
  public static synchronized List<SearchResultBean> getSearchResultBeans(
      List<Search.Result> results, Locale locale) {
    List<SearchResultBean> searchResultBeans = new LinkedList<SearchResultBean>();
    try {
      for (Search.Result result : results) {
        searchResultBeans.add(new SearchResultBean(result, locale));
      }
      while (searchResultBeans.size() < Config.getConfig().getSearch().getMaxSearchResults()) {
        searchResultBeans.add(new SearchResultBean());
      }
    } catch (java.util.ConcurrentModificationException ce) {
      // bit of a hack to say the least

      try {
        Thread.sleep(50);
      } catch (Exception e) {
      }
      return getSearchResultBeans(results, locale);
    }
    return searchResultBeans;
  }
示例#14
0
 private static void deleteCache(Configuration conf, MRAsyncDiskService asyncDiskService)
     throws IOException {
   List<CacheStatus> deleteSet = new LinkedList<CacheStatus>();
   // try deleting cache Status with refcount of zero
   synchronized (cachedArchives) {
     for (Iterator<String> it = cachedArchives.keySet().iterator(); it.hasNext(); ) {
       String cacheId = (String) it.next();
       CacheStatus lcacheStatus = cachedArchives.get(cacheId);
       if (lcacheStatus.refcount == 0) {
         // delete this cache entry from the global list
         // and mark the localized file for deletion
         deleteSet.add(lcacheStatus);
         it.remove();
       }
     }
   }
   // do the deletion asynchronously, after releasing the global lock
   Thread cacheFileCleaner =
       new Thread(new CacheFileCleanTask(asyncDiskService, FileSystem.getLocal(conf), deleteSet));
   cacheFileCleaner.start();
 }
示例#15
0
 /**
  * Hidden ones are not included
  *
  * @return Not null, read only and of type <tt>MetaProperty</tt>.
  */
 public Collection getMetaPropertiesCalculated() throws XavaException {
   if (metaPropertiesCalculated == null) {
     metaPropertiesCalculated = new ArrayList();
     Iterator it = getMetaProperties().iterator();
     while (it.hasNext()) {
       MetaProperty metaProperty = (MetaProperty) it.next();
       if (metaProperty.isCalculated()) {
         metaPropertiesCalculated.add(metaProperty);
       }
     }
   }
   return metaPropertiesCalculated;
 }
 private MetaProperty getMetaProperty(int i) {
   return (MetaProperty) metaProperties.get(i);
 }
示例#17
0
 public List getRemainingPropertiesNames() throws XavaException {
   List result = new ArrayList(getMetaModel().getRecursiveQualifiedPropertiesNames());
   result.removeAll(getPropertiesNames());
   return result;
 }
示例#18
0
 /** For dynamically remove all properties to this tab */
 public void clearProperties() {
   if (propertiesNames == null) return;
   propertiesNames.clear();
   resetAfterAddRemoveProperty();
 }
示例#19
0
 /** For dynamically remove properties to this tab */
 public void removeProperty(int index) {
   if (propertiesNames == null) return;
   propertiesNames.remove(index);
   resetAfterAddRemoveProperty();
 }
示例#20
0
 /** For dynamically remove properties to this tab */
 public void removeProperty(String propertyName) {
   if (propertiesNames == null) return;
   propertiesNames.remove(propertyName);
   resetAfterAddRemoveProperty();
 }
示例#21
0
 /** For dynamically add properties to this tab */
 public void addProperty(int index, String propertyName) {
   if (propertiesNames == null) return;
   propertiesNames.add(index, propertyName);
   resetAfterAddRemoveProperty();
 }