Exemplo n.º 1
0
  @Test
  public void testEnums() {
    sql2o
        .createQuery(
            "create table EnumTest(id int identity primary key, enum_val varchar(10), enum_val2 int) ")
        .executeUpdate();

    sql2o
        .createQuery("insert into EnumTest(enum_val, enum_val2) values (:val, :val2)")
        .addParameter("val", TestEnum.HELLO)
        .addParameter("val2", TestEnum.HELLO.ordinal())
        .addToBatch()
        .addParameter("val", TestEnum.WORLD)
        .addParameter("val2", TestEnum.WORLD.ordinal())
        .addToBatch()
        .executeBatch();

    List<EntityWithEnum> list =
        sql2o
            .createQuery("select id, enum_val val, enum_val2 val2 from EnumTest")
            .executeAndFetch(EntityWithEnum.class);

    assertThat(list.get(0).val, is(TestEnum.HELLO));
    assertThat(list.get(0).val2, is(TestEnum.HELLO));
    assertThat(list.get(1).val, is(TestEnum.WORLD));
    assertThat(list.get(1).val2, is(TestEnum.WORLD));

    TestEnum testEnum =
        sql2o.createQuery("select 'HELLO' from (values(0))").executeScalar(TestEnum.class);
    assertThat(testEnum, is(TestEnum.HELLO));

    TestEnum testEnum2 =
        sql2o.createQuery("select NULL from (values(0))").executeScalar(TestEnum.class);
    assertThat(testEnum2, is(nullValue()));
  }
 public String getPackedVersionString() {
   ICFLibAnyObj scopeDef;
   ICFBamVersionObj versionLeafDef = getVersionLeaf();
   List<String> invertedNodeNames = new ArrayList<String>();
   while (versionLeafDef != null) {
     invertedNodeNames.add(getVersionStringForLeafDef(versionLeafDef));
     scopeDef = versionLeafDef.getObjScope();
     if (scopeDef == null) {
       versionLeafDef = null;
     } else if (scopeDef instanceof ICFBamMinorVersionObj) {
       versionLeafDef = (ICFBamMinorVersionObj) scopeDef;
     } else if (scopeDef instanceof ICFBamMajorVersionObj) {
       versionLeafDef = (ICFBamMajorVersionObj) scopeDef;
     } else if (scopeDef instanceof ICFBamVersionObj) {
       versionLeafDef = (ICFBamVersionObj) scopeDef;
     } else {
       versionLeafDef = null;
     }
   }
   String ret = "";
   for (int idx = invertedNodeNames.size() - 1; idx >= 0; idx--) {
     if (ret.length() == 0) {
       ret = invertedNodeNames.get(idx);
     } else {
       ret = ret + invertedNodeNames.get(idx);
     }
   }
   return (ret);
 }
 // 根据推荐的movie的ID,获得movie的详细信息
 public ArrayList<MovieInfo> getMovieByMovieId(List<RecommendedItem> recommendations) {
   ArrayList<MovieInfo> movieList = new ArrayList<MovieInfo>();
   try {
     String sql = "";
     conn = ConnectToMySQL.getConnection();
     for (int i = 0; i < recommendations.size(); i++) {
       sql =
           "select m.name,m.published_year,m.type from movies m where m.id="
               + recommendations.get(i).getItemID()
               + "";
       ps = conn.prepareStatement(sql);
       rs = ps.executeQuery();
       while (rs.next()) {
         MovieInfo movieInfo = new MovieInfo();
         movieInfo.setName(rs.getString(1));
         movieInfo.setPublishedYear(rs.getString(2));
         movieInfo.setType(rs.getString(3));
         movieInfo.setPreference(recommendations.get(i).getValue());
         movieList.add(movieInfo);
       }
     }
   } catch (Exception e) {
     // TODO: handle exception
     e.printStackTrace();
   } finally {
     closeAll();
   }
   return movieList;
 }
Exemplo n.º 4
0
  /**
   * @param request
   * @param tableCategoryId
   * @paqram includeAction if true, will load webactions also
   * @return elements are Table or WebAction
   */
  public List getChildrenOfTableCategory(
      HttpServletRequest request, int tableCategoryId, boolean includeAction) {
    TableManager manager = TableManager.getInstance();

    WebAction action;
    ArrayList cats = new ArrayList();
    Connection conn = null;
    HashMap webActionEnv = null;
    Table table;
    UserWebImpl userWeb =
        ((UserWebImpl)
            WebUtils.getSessionContextManager(request.getSession())
                .getActor(nds.util.WebKeys.USER));

    TableCategory tc = manager.getTableCategory(tableCategoryId);
    List children = tc.children();
    ArrayList catschild = new ArrayList();
    try {
      if (includeAction) {
        conn = QueryEngine.getInstance().getConnection();
        webActionEnv = new HashMap();
        webActionEnv.put("connection", conn);
        webActionEnv.put("httpservletrequest", request);
        webActionEnv.put("userweb", userWeb);
      }
      for (int j = 0; j < children.size(); j++) {
        if (children.get(j) instanceof Table) {
          table = (Table) children.get(j);
          if (!table.isMenuObject()) {
            continue;
          }
          try {
            WebUtils.checkTableQueryPermission(table.getName(), request);
          } catch (NDSSecurityException e) {
            continue;
          }
          // table is ok for current user to list
          catschild.add(table);
        } else if (children.get(j) instanceof WebAction) {
          if (includeAction) {
            action = (WebAction) children.get(j);
            if (action.canDisplay(webActionEnv)) catschild.add(action);
          }
        } else {
          throw new NDSRuntimeException(
              "Unsupported element in TableCategory children:" + children.get(j).getClass());
        }
      }
    } catch (Throwable t) {
      logger.error("Fail to load subsystem tree", t);
    } finally {
      try {
        if (conn != null) conn.close();
      } catch (Throwable e) {
      }
    }
    return catschild;
  }
 /*
  * Searches for the list of sensors which are located at the given point (as list of Strings)
  * */
 public static List<String> searchForSensors(Point p) {
   List l = new Vector<String>();
   for (int i = 0; i < coordinates.size(); i++) {
     if (coordinates.get(i) == p) {
       l.add(sensors.get(i));
     }
   }
   return l;
 }
 /*
  * Searches for the list of sensors which are located at the given point (comma separated)
  * */
 public static String searchForSensors_String(Point p) {
   StringBuilder s = new StringBuilder("");
   for (int i = 0; i < coordinates.size(); i++) {
     if (coordinates.get(i) == p) {
       s.append(sensors.get(i)).append(" ");
     }
   }
   return s.toString().trim().replace(" ", SEPARATOR);
 }
Exemplo n.º 7
0
  @Test
  public void testExecuteAndFetchResultSet() throws SQLException {
    List<Integer> list =
        sql2o
            .createQuery(
                "select 1 val from (values(0)) union select 2 from (values(0)) union select 3 from (values(0))")
            .executeScalarList();

    assertEquals((int) list.get(0), 1);
    assertEquals((int) list.get(1), 2);
    assertEquals((int) list.get(2), 3);
  }
Exemplo n.º 8
0
 {
     //create out of bounds exception emailList.get(-1)
     if (emailList.get(i) == emailList.get(i-1))
     {
         dupEmailCount++;
     }
     else
     {
         //insert domain email, dupEmailCount into hashtable
         domainCount.put(emailList.get(i), dupEmailCount);
         dupEmailCount = 0;
     }
 }
Exemplo n.º 9
0
 /**
  * MU_FAVORITE
  *
  * @throws Exception cyl
  * @param request
  * @return elements are Table or WebAction and menu list
  * @paqram includeAction if true?not now
  */
 public List getSubSystemsOfmufavorite(HttpServletRequest request) throws Exception {
   ArrayList mufavorite = new ArrayList();
   TableManager manager = TableManager.getInstance();
   // Table table;
   try {
     UserWebImpl userWeb =
         ((UserWebImpl)
             WebUtils.getSessionContextManager(request.getSession())
                 .getActor(nds.util.WebKeys.USER));
     int userid = userWeb.getUserId();
     List al =
         QueryEngine.getInstance()
             .doQueryList(
                 "select t.ad_table_id,t.fa_menu,t.menu_re,t.IS_REPORT from MU_FAVORITE t where t.ownerid="
                     + String.valueOf(userid)
                     + " group by t.ad_table_id,t.menu_no,t.fa_menu,t.menu_re,t.IS_REPORT,t.creationdate order by t.menu_no,t.creationdate asc");
     logger.debug("MU_FAVORITE size is " + String.valueOf(al.size()));
     if (al.size() > 0) {
       for (int i = 0; i < al.size(); i++) {
         // ArrayList catschild= new ArrayList();
         List als = (List) al.get(i);
         String fa_menu = (String) als.get(1);
         String menu_re = (String) als.get(2);
         String isreport = (String) als.get(3);
         int table_id = Tools.getInt(als.get(0), -1);
         Table table = manager.getTable(table_id);
         logger.debug(table.getName());
         /*
         if(!table.isMenuObject()){
                     	continue;
                     	//because many table is webaction not ismenuobject
                     }*/
         try {
           WebUtils.checkTableQueryPermission(table.getName(), request);
         } catch (NDSSecurityException e) {
           continue;
         }
         logger.debug("add_table    ->" + table.getName());
         ArrayList row = new ArrayList();
         row.add(fa_menu);
         row.add(menu_re);
         row.add(isreport);
         row.add(table);
         mufavorite.add(row);
       }
     }
   } catch (Throwable t) {
     logger.error("Fail to load mufavorite", t);
   }
   return mufavorite;
 }
Exemplo n.º 10
0
  /**
   * @param request
   * @param subSystemId
   * @return
   */
  private boolean containsViewableActions(HttpServletRequest request, SubSystem ss) {
    List<WebAction> list = ss.getWebActions();
    Connection conn = null;
    try {
      UserWebImpl userWeb =
          ((UserWebImpl)
              WebUtils.getSessionContextManager(request.getSession())
                  .getActor(nds.util.WebKeys.USER));
      conn = QueryEngine.getInstance().getConnection();
      HashMap webActionEnv = new HashMap();
      webActionEnv.put("connection", conn);
      webActionEnv.put("httpservletrequest", request);
      webActionEnv.put("userweb", userWeb);

      for (int i = 0; i < list.size(); i++) {
        WebAction wa = list.get(i);
        if (wa.canDisplay(webActionEnv)) {
          return true;
        }
      }
    } catch (Throwable t) {
      logger.error("Fail to load subsystem webaction", t);
    } finally {
      try {
        if (conn != null) conn.close();
      } catch (Throwable te) {
      }
    }
    return false;
  }
  @WebMethod
  public Response insertKebutuhanMaintenance(
      int idAset, List<Integer> idLogistik, List<Integer> jumlahKebutuhan) throws SQLException {
    String query =
        "INSERT INTO " + KEBUTUHAN_MAINTENANCE_TABLE + " (id_aset, id_logistik, jumlah) VALUES";

    for (int i = 0; i < idLogistik.size(); ++i) {
      query += " (" + idAset + ", " + idLogistik.get(i) + ", " + jumlahKebutuhan.get(i) + ")";
      if (i != idLogistik.size() - 1) query += ",";
    }

    int numRowAffected = executeUpdateQueryAndGetRowCount(query);

    if (numRowAffected > 0) return new Response(true);
    else return new Response(false);
  }
Exemplo n.º 12
0
  public static ArrayList getFjList(String sid) {
    ArrayList result = new ArrayList();
    String strSql =
        "select SID,File_Name,Ext_Name,File_Size from  t_docs_fj where state='1' and parent_sid="
            + sid;
    CommonDao dao = CommonDao.GetOldDatabaseDao();
    List lst = dao.fetchAll(strSql);
    if (lst != null && lst.size() > 0) {
      for (int i = 0; i < lst.size(); i++) {
        Object[] arr = (Object[]) lst.get(i);
        result.add(arr[1]);
        result.add(arr[2]);
        if (arr[3] != null) {
          Float fileSize = Float.parseFloat(arr[3].toString()) * 1000;
          result.add(fileSize);
        } else {
          result.add(0);
        }
        result.add(arr[0]);
      }
    }
    dao.getSessionFactory().close();
    return result;
    /*Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    ArrayList result = new ArrayList();
    String strSql = "select * from  t_docs_fj where state='1' and parent_sid="
    		+ sid;
    try {
    	conn = DataManager.getConnection();
    	stmt = conn.createStatement();
    	rs = stmt.executeQuery(strSql);
    	while (rs.next()) {
    		result.add(rs.getString("File_Name"));
    		result.add(rs.getString("Ext_Name"));
    		result.add(""
    				+ Float.valueOf(rs.getString("File_Size")).floatValue()
    				* 1000.0);
    		result.add(rs.getString("SID"));
    		result.add(FileUtil.getDocumentPath());
    	}
    } catch (Exception ex) {
    	ex.printStackTrace();
    }

    finally {
    	try {
    		if (rs != null)
    			rs.close();
    		if (stmt != null)
    			stmt.close();
    		if (conn != null)
    			conn.close();
    	} catch (Exception ex) {
    		ex.printStackTrace();
    	}
    }*/

  }
Exemplo n.º 13
0
 public List<PromoterRowGateway> findAll() {
   List result = new ArrayList();
   List promoters = jdbcTemplate.queryForList(findAllStatement);
   for (int i = 0; i < promoters.size(); i++)
     result.add(PromoterRowGateway.load(dataSource, (Map) promoters.get(i)));
   return result;
 }
Exemplo n.º 14
0
  public static boolean isZero(List list, String col) {
    if (list == null) {
      return false;
    }
    boolean b = false;
    int i, num = 0;
    String v = null;
    Map m = null;
    double dv = 0;

    num = list.size();
    for (i = 0; i < num; i++) {
      m = (Map) list.get(i);
      v = (String) m.get(col);
      // if(f.empty(v)){return true;}
      if (f.empty(v)) {
        continue;
      }
      // System.out.println(v);
      v = f.v(v);
      dv = f.getDouble(v, 0);
      // if(dv==0){return true;}
      if (dv > 0) {
        return false;
      }
      b = true;
    }

    return b;
  }
Exemplo n.º 15
0
  @Test
  public void testJodaTime() {

    sql2o
        .createQuery("create table testjoda(id int primary key, joda1 datetime, joda2 datetime)")
        .executeUpdate();

    sql2o
        .createQuery("insert into testjoda(id, joda1, joda2) values(:id, :joda1, :joda2)")
        .addParameter("id", 1)
        .addParameter("joda1", new DateTime())
        .addParameter("joda2", new DateTime().plusDays(-1))
        .addToBatch()
        .addParameter("id", 2)
        .addParameter("joda1", new DateTime().plusYears(1))
        .addParameter("joda2", new DateTime().plusDays(-2))
        .addToBatch()
        .addParameter("id", 3)
        .addParameter("joda1", new DateTime().plusYears(2))
        .addParameter("joda2", new DateTime().plusDays(-3))
        .addToBatch()
        .executeBatch();

    List<JodaEntity> list =
        sql2o.createQuery("select * from testjoda").executeAndFetch(JodaEntity.class);

    assertTrue(list.size() == 3);
    assertTrue(list.get(0).getJoda2().isBeforeNow());
  }
Exemplo n.º 16
0
 /**
  * Returns the accessor for column with a given index.
  *
  * @param columnIndex 1-based column index
  * @return Accessor
  * @throws SQLException if index is not valid
  */
 private Cursor.Accessor getAccessor(int columnIndex) throws SQLException {
   try {
     return accessorList.get(columnIndex - 1);
   } catch (IndexOutOfBoundsException e) {
     throw new SQLException("invalid column ordinal: " + columnIndex);
   }
 }
  /**
   * 領域マスタの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);
  }
  @Override
  public String execute() throws Exception {
    Connection conn = null;
    List<Slice> slices = new LinkedList<Slice>();
    try {
      conn = Constants.DATASOURCE.getConnection();
      PreparedStatement stmt =
          conn.prepareStatement(SqlQuery.SERVICES_ON_HOSTS_BY_PROJECT.getSql());
      stmt.setInt(1, idProject);

      ResultSet rs = stmt.executeQuery();

      while (rs.next()) {
        String name = rs.getString("name") == null ? rs.getString("ip") : rs.getString("name");
        int count = rs.getInt("conteggio");
        Slice slice = new Slice();
        slice.setLabel(name + "[" + count + "]");
        slice.setTooltip(name + "\n" + count + " running services");
        slice.setValue(count);
        slices.add(slice);
      }
      rs.close();
      stmt.close();
    } catch (SQLException e) {
      return ERROR;
    } finally {
      if (conn != null) conn.close();
    }
    String[] colors = {
      "000000", "0000ff", "00ffff", "00ff00", "ffff00", "ff0000", "ff00ff", "ffffff"
    };
    if (slices.size() != 0) {
      int increment = 0;
      for (Slice slice : slices) {
        slice.setColour("#" + colors[increment]);
        increment = (increment + 1) % colors.length;
      }
      if (slices.size() % colors.length == 1) slices.get(slices.size() - 1).setColour(colors[1]);
    }
    pieChart = new PieChart();
    List<ElementPie> elements = new LinkedList<ElementPie>();
    ElementPie element = new ElementPie();
    element.setAlpha(0.9f);
    pieChart.setTitle(
        new Title(
            "Services Distribution",
            "{" + getText("avgProjectActivityPieChart.title.style") + "}"));
    element.setValues(slices);
    element.setGradientFill(true);
    element.setRadius(50);
    element.setStartAngle(0);
    elements.add(element);
    pieChart.setBg_colour(getText("chart.defaultBgColor"));
    pieChart.setBorder(1);
    pieChart.setAnimate(true);
    pieChart.setElements(elements);

    return SUCCESS;
  }
Exemplo n.º 19
0
 @Override
 public <T> T searchForOne(String sql, Class<T> clazz, List<Object> params) throws Exception {
   List<T> list = searchForList(sql, clazz, params);
   if (list != null && list.size() > 0) {
     return list.get(0);
   }
   return null;
 }
 @Test
 public void testGetSplitsWithSkipScanFilter() throws Exception {
   long ts = nextTimestamp();
   TableRef table = initTableValues(ts, 3, 5);
   NavigableMap<HRegionInfo, ServerName> regions = getRegions(table);
   List<KeyRange> splits = getSplits(table, scan, regions, scanRanges);
   assertEquals(
       "Unexpected number of splits: " + splits.size(), expectedSplits.size(), splits.size());
   for (int i = 0; i < expectedSplits.size(); i++) {
     assertEquals(expectedSplits.get(i), splits.get(i));
   }
   assertEquals(
       "Unexpected number of splits: " + splits.size(), expectedSplits.size(), splits.size());
   for (int i = 0; i < expectedSplits.size(); i++) {
     assertEquals(expectedSplits.get(i), splits.get(i));
   }
 }
Exemplo n.º 21
0
 /**
  * 事实表和关联报表属于当前传入数组的交叉报表
  *
  * @param request
  * @return elements are ArrayList, first is cxtab id, second is cxtab name
  */
 public List getCxtabs(HttpServletRequest request, int tableCategoryId) {
   List tables = getChildrenOfTableCategory(request, tableCategoryId, false);
   ArrayList<Integer> al = new ArrayList();
   for (int i = 0; i < tables.size(); i++) {
     al.add(((Table) tables.get(i)).getId());
   }
   return getCxtabs(request, al);
 }
Exemplo n.º 22
0
 public static ArrayList<String> getListOfSensors(String envelope) throws ParseException {
   Geometry geom = new WKTReader().read(envelope);
   List listEnvelope = geoIndex.query(geom.getEnvelopeInternal());
   ArrayList<String> sensors = new ArrayList<String>();
   for (int i = 0; i < listEnvelope.size(); i++) {
     sensors.add(searchForSensors_String((Point) listEnvelope.get(i)));
   }
   return sensors;
 }
Exemplo n.º 23
0
  /**
   * Get viewable subsystem list
   *
   * @param request
   * @return never null, elements are nds.schema.SubSystem
   */
  public List getSubSystems(HttpServletRequest request) {
    UserWebImpl userWeb =
        ((UserWebImpl)
            WebUtils.getSessionContextManager(request.getSession())
                .getActor(nds.util.WebKeys.USER));
    ArrayList subs = new ArrayList();
    if (userWeb.getUserId() == userWeb.GUEST_ID) {
      return subs;
    }
    List al = (List) userWeb.getProperty("subsystems"); // elements are subystem.id
    TableManager manager = TableManager.getInstance();
    if (al != null) {

      for (int i = 0; i < al.size(); i++) {
        int sid = ((Integer) al.get(i)).intValue();
        SubSystem ss = manager.getSubSystem(sid);
        if (ss != null) subs.add(ss);
      }
    } else {
      // search all tablecategoris for subsystem
      // add users subsystems param
      al = new ArrayList();
      String[] sub_list;
      try {
        String subsystems =
            (String)
                QueryEngine.getInstance()
                    .doQueryOne("SELECT subsystems from users where id=" + userWeb.getUserId());
        if (Validator.isNotNull(subsystems)) {
          sub_list = subsystems.split(",");
          for (int m = 0; m < sub_list.length; m++) {
            SubSystem usersub = manager.getSubSystem(sub_list[m].trim());

            if (usersub != null) {
              if (usersub.getId() == 10) continue;
              al.add(new Integer(usersub.getId()));
              subs.add(usersub);
            }
          }
          userWeb.setProperty("subsystems", al);
          return subs;
        }
      } catch (QueryException e) {
        logger.error("Fail to load subsystems from users", e);
      }

      for (int i = 0; i < manager.getSubSystems().size(); i++) {
        SubSystem ss = (SubSystem) manager.getSubSystems().get(i);
        if (containsViewableChildren(request, ss)) {
          al.add(new Integer(ss.getId()));
          subs.add(ss);
        }
      }
      userWeb.setProperty("subsystems", al);
    }
    return subs;
  }
Exemplo n.º 24
0
 /**
  * Returns index of the object a <code>List</code> object of <code>PersistentObject</code>s that
  * contains an encoded key (<code>getEncodedKey()</code>).
  *
  * @param list <code>List</code> of objects to search.
  * @param encodedKey key obtained via <code>getEncodedKey()</code>.
  * @return index of object on list or <code>-1</code> if not found.
  * @see net.sf.jrf.domain.PersistentObject#getEncodedKey()
  * @see #findByKey(List,String)
  */
 public static int findIndexByKey(List list, String encodedKey) {
   for (int i = 0; i < list.size(); i++) {
     PersistentObject p = (PersistentObject) list.get(i);
     if (p.getEncodedKey().equals(encodedKey)) {
       return i;
     }
   }
   return -1;
 }
 /* (non-Javadoc)
  * @see org.rimudb.generic.binders.IIterativeResultSetBinder#processSingleResultSet(java.sql.ResultSet, java.lang.Object[])
  */
 public Object processSingleResultSet(ResultSet rs) throws RimuDBException {
   if (tableList == null) {
     throw new IllegalArgumentException("initialize() method must initialize the table");
   }
   DataObject dataObjectArray[] = new DataObject[dataObjectClasses.length];
   for (int i = 0; i < dataObjectArray.length; i++) {
     dataObjectArray[i] = tableList.get(i).createDataObject(rs);
   }
   return dataObjectArray;
 }
 String makeStringFromList(List l) {
   StringBuilder sb = new StringBuilder();
   for (int i = 0; i < l.size(); i++) {
     Object o = l.get(i);
     if (o == null) sb.append("null");
     else sb.append(o.toString());
     if (i < l.size() - 1) sb.append(SEPARATOR);
   }
   return sb.toString();
 }
Exemplo n.º 27
0
 /**
  * Convert the input parameter values to its types object values.
  *
  * @param params The input params
  * @return The typed object values
  * @throws DataServiceFault
  */
 public static Object[] convertInputParamValues(List<InternalParam> params)
     throws DataServiceFault {
   Object[] result = new Object[params.size()];
   InternalParam param;
   for (int i = 0; i < result.length; i++) {
     param = params.get(i);
     result[i] = convertInputParamValue(param.getValue().getValueAsString(), param.getSqlType());
   }
   return result;
 }
Exemplo n.º 28
0
  /*
   * Builds geographic geoIndex from list of sensors currently loaded in the system
   * */
  public static void buildGeoIndex() {

    geoIndex = new STRtree();
    geometryFactory = new GeometryFactory();
    sensors = new Vector<String>();
    coordinates = new Vector<Point>();

    getListOfSensors();

    for (int i = 0; i < sensors.size(); i++) {
      geoIndex.insert(coordinates.get(i).getEnvelopeInternal(), coordinates.get(i));
      logger.warn(
          sensors.get(i)
              + " : "
              + coordinates.get(i)
              + " : "
              + searchForSensors_String(coordinates.get(i)));
    }
    geoIndex.build();
  }
Exemplo n.º 29
0
  /**
   * GET SMIC WIP FILEs
   *
   * @throws IOException
   */
  public void GetCpYieldFiles() {

    try {
      logger.debug("fileInUrl " + fileInUrl.getPath());
      List fileList = Methods.getFiles(fileInUrl);
      fileList = null != fileList ? fileList : new ArrayList();

      for (int i = 0; i < fileList.size(); i++) {
        File txtFile = (File) fileList.get(i);
        String fileName = txtFile.getName();
        // 1.0 Check File Status can read, write
        if (txtFile.canRead() && txtFile.canWrite()) {}

        // if (file_name.substring(4, 5).equals("B")) {
        // System.out.println(file_name+" is Bump's File");
        if (this.parserCpYieldTxt(txtFile) == false) {
          logger.info(fileName + " is Parser false");
          // alert.setSubject(SystemContext.getConfig("config.himax.mail.subject") + " - " +
          // fileName + " is Parser false");
          // alert.sendNoFile("CP Yield Parser fail:" + txtFile);
          Methods.copyFile(txtFile, new File(fileErrorUrl + "\\" + fileName));
          txtFile.delete();
        } else {

          // logger.info(fileName + " is Parser complete");
          // Methods.copyFile(txtFile, new File(fileOutUrl + "\\" + fileName));
          // txtFile.delete();
        }
        /*} else {
            logger.info(file_name + " is not Bump's File");
            alert.sendNoFile("ECOA This File is not Bump's File:" + excelFile);
            mod.copyFile(excelFile, new File(fileErrorUrl + "\\" + file_name));
            excelFile.delete();

            logger.info(file_name+" is not BUMP's File");
        }*/
      }
    } catch (Exception e) {
      StackTraceElement[] messages = e.getStackTrace();

      int length = messages.length;
      String error = "";
      alert.setSubject(
          SystemContext.getConfig("config.himax.mail.subject") + " - " + e.getMessage());
      for (int i = 0; i < length; i++) {
        error = error + "toString:" + messages[i].toString() + "\r\n";
      }
      alert.sendNoFile(error);
      e.printStackTrace();
      logger.error(error);
    }
  }
  public String buildServiceOptions(String rule) throws SQLException {
    List services = NotificationFactory.getInstance().getServiceNames();
    Collections.sort(
        services,
        new Comparator() {
          public int compare(Object o1, Object o2) {
            return ((String) o1).compareToIgnoreCase((String) o2);
          }
        });
    StringBuffer buffer = new StringBuffer();

    for (int i = 0; i < services.size(); i++) {
      if (rule != null && rule.indexOf((String) services.get(i)) > 0) {
        buffer.append(
            "<option selected VALUE='" + services.get(i) + "'>" + services.get(i) + "</option>");
      } else {
        buffer.append("<option VALUE='" + services.get(i) + "'>" + services.get(i) + "</option>");
      }
    }

    return buffer.toString();
  }