Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public commandState select(queryParsedData data) throws SQLException, IOException, SAXException, ParserConfigurationException {
- commandState cS = new commandState();
- java.sql.SQLException ex = new java.sql.SQLException();
- String XMLpath = data.getDataBaseName()+System.getProperty("file.separator")+data.getTableName()+".xml";
- cachedTable table = cachedTables.get(chashedPathes.indexOf(XMLpath));
- if(chashedPathes.indexOf(XMLpath)< 0){
- cS.setExecuted(false);
- System.out.println(XMLpath + " : Schema Not found");
- throw ex;
- }else {
- ArrayList<ArrayList<Object>> selected = new ArrayList<>();
- if(!((data.getCondition().contains("="))||(data.getCondition().contains(">"))||(data.getCondition().contains("<")))){
- if (data.isSelectAll()){
- for (int i=0;i<table.getRows().size();i++) {
- ArrayList<Object> NEW = new ArrayList<>();
- String temp = new String();
- for(Object s : table.getRows().get(i).keySet())
- temp = temp.concat("\n").concat((String) table.getRows().get(i).get(s)) ;
- NEW.add(temp);
- selected.add(NEW);
- }
- }
- else{
- ArrayList<Object> NEW = new ArrayList<>();
- for (int i=0;i<table.getRows().size();i++) {
- String temp = new String();
- boolean flag = false;
- for(Object s : table.getRows().get(i).keySet()) {
- NEW = new ArrayList<>();
- for(Object S : data.getData().keySet()){
- if (s.equals(S)) {
- temp = temp.concat("\n").concat((String) table.getRows().get(i).get(s));
- flag = true;
- }
- }
- if(flag)
- NEW.add(temp);
- }
- }
- if (!NEW.isEmpty())
- selected.add(NEW);
- }
- cS.setArray(selected);
- }
- else{
- if (data.isSelectAll()){
- String conditionString = data.getCondition();
- String[] condition = conditionString.split(" *= *| *< *| *> *");
- boolean flag = false;
- ArrayList<Object> NEW = new ArrayList<>();
- for (int i=0;i<table.getRows().size();i++) {
- NEW = new ArrayList<>();
- String temp = new String();
- for(Object s : table.getRows().get(i).keySet()) {
- temp = new String();
- if (util.conditionValidator((String) s,(String) table.getRows().get(i).get(s),data)) {
- for(Object F : table.getRows().get(i).keySet()) {
- temp = temp.concat("\n").concat((String) table.getRows().get(i).get(F));
- flag = true;
- }
- }
- if (flag)
- NEW.add(temp);
- if(!(NEW.size()==0))
- selected.add(NEW);
- }
- }
- }
- else{
- ArrayList<Object> NEW = new ArrayList<>();
- for (int i=0;i<table.getRows().size();i++) {
- String temp = new String();
- boolean flag = false;
- for(Object s : table.getRows().get(i).keySet()) {
- NEW = new ArrayList<>();
- for(Object S : data.getData().keySet()){
- String conditionString = data.getCondition();
- String[] condition = conditionString.split(" *= *| *< *| *> *");
- System.out.println("SELECT " + condition[0]+ " "+ s);
- if (condition[0].equals(s)) {
- flag = false;
- System.out.println("SELECT " + condition[0]);
- System.out.println("KKKKKKKKKKKK ");
- if (util.conditionValidator((String) s,(String) table.getRows().get(i).get(s),data)) {
- temp = temp.concat("\n").concat((String) table.getRows().get(i).get(s));
- flag = true;
- }
- if(flag)
- NEW.add(temp);
- }
- }
- if (NEW.size()!=0)
- selected.add(NEW);
- }
- }
- }
- cS.setArray(selected);
- }
- }
- System.out.println("ROWS "+table.getRows());
- System.out.println("VALUES "+table.getCoulmnsValues());
- return cS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement