public void setNewParent(CaoNode parent) { properties.put(NEW_PARENT, parent); }
@Override public void setObject(UiComponent component, String name, Object value) { properties.put(name, value); }
public void setNewParent(CaoNode parent) { properties.put(NEW_PARENT, parent); }
public void putAll(String prefix, Map<?,?> map) { for (Entry<?, ?> entry : map.entrySet()) put(String.valueOf(prefix + entry.getKey()), entry.getValue()); }
private void addFilter(String name, String value, MProperties prop, StringBuilder sql) { prop.put(name, value); if (value.startsWith("*") || value.endsWith("*")) sql.append(name + "_ like $"+name+"$ "); else sql.append(name + "_=$"+name+"$ "); }
@Override public boolean reloadAccount() { { // find user name groups = new HashSet<>(); attr = new MProperties(); int cnt = 0; for (Principal principal : subject.getPrincipals()) { switch (principal.getClass().getSimpleName()) { case "UserPrincipal": userName = principal.getName(); break; case "RolePrincipal": groups.add(principal.getName()); break; } attr.put(principal.getClass().getSimpleName() + "." + cnt, principal.getName()); cnt++; } } return true; }
@Override public void reload() throws CaoException { properties.clear(); for (java.util.Map.Entry<String, Object> entry : getOriginalElement().entrySet()) properties.put(entry.getKey(), entry.getValue()); }
@Override public void setObject(UiComponent component, String name, Object value) { properties.put(toName(component.getName(),name), value); }
@Override public boolean setNodeScope(UUID nodeId, int scope) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", nodeId); prop.put("value", scope); sta = con.createStatement("UPDATE " + prefix + "_node_ SET scope_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
@Override public boolean setCasePriority(UUID caseId, int priority) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", caseId); prop.put("value", priority); sta = con.createStatement("UPDATE " + prefix + "_case_ SET priority_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
@Override public boolean setNodePriority(UUID nodeId, int priority) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", nodeId); prop.put("value", priority); sta = con.createStatement("UPDATE " + prefix + "_node_ SET priority_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
@Override public boolean setCaseScope(UUID caseId, int scope) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", caseId); prop.put("value", scope); sta = con.createStatement("UPDATE " + prefix + "_case_ SET scope_=$value$ WHERE id_=$id$"); int res = sta.executeUpdate(prop); con.close(); return res == 1; } catch (Exception e) { throw new IOException(e); } }
@Override public Result<PCaseInfo> getCases(STATE_CASE state) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_"); } else { prop.put("state", state); sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_ WHERE state_=$state$"); } DbResult res = sta.executeQuery(prop); return new SqlResultCase(con,res); } catch (Exception e) { throw new IOException(e); } }
@Override public void deleteCaseAndFlowNodes(UUID id) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); { DbStatement sta = con.createStatement("DELETE FROM " + prefix + "_case_ WHERE id_=$id$"); sta.execute(prop); } { DbStatement sta = con.createStatement("DELETE FROM " + prefix + "_node_ WHERE case_=$id$"); sta.execute(prop); } con.commit(); con.close(); } catch (Exception e) { throw new IOException(e); } }
@Override public PEngine loadEngine() throws IOException, NotFoundException { PEngine engine = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", "engine"); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_engine_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); engine = new PEngine(); engine.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (engine == null) throw new NotFoundException("engine"); return engine; }
@Override public PCase loadCase(UUID id) throws IOException, NotFoundException { PCase caze = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_case_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); caze = new PCase(); caze.readExternal(new ObjectInputStream(in)); } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (caze == null) throw new NotFoundException("case",id); return caze; }
@Override public Result<PNodeInfo> getSignalFlowNodes(STATE_NODE state, String signal) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { prop.setString("signal", "%" + PNode.getSignalAsString(signal) + "%"); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE signal_ like $signal$"); } else { prop.setString("signal", "%" + PNode.getSignalAsString(signal) + "%"); prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$ and signal_ like $signal$"); } DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) { throw new IOException(e); } }
@Override public Result<PNodeInfo> getScheduledFlowNodes(STATE_NODE state, long scheduled) throws IOException { DbConnection con = null; try { con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; if (state == null) { prop.setLong("scheduled", scheduled); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE scheduled_ <= $scheduled$"); } else { prop.setLong("scheduled", scheduled); prop.put("state", state); sta = con.createStatement("SELECT "+NODE_COLUMNS+" FROM " + prefix + "_node_ WHERE state_=$state$ and scheduled_ <= $scheduled$"); } DbResult res = sta.executeQuery(prop); return new SqlResultNode(con,res); } catch (Exception e) { try { if (con != null) con.close(); } catch (Exception e2) {} throw new IOException(e); } }
@Override public PCaseInfo loadCaseInfo(UUID caseId) throws IOException { try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); DbStatement sta = null; prop.put("id", caseId); sta = con.createStatement("SELECT "+CASE_COLUMNS+" FROM " + prefix + "_case_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (!res.next()) { res.close(); con.close(); return null; } PCaseInfo out = newPCase(res); res.close(); con.close(); return out; } catch (Exception e) { throw new IOException(e); } }
@Override public PNode loadFlowNode(UUID id) throws IOException, NotFoundException { PNode node = null; try { DbConnection con = pool.getConnection(); MProperties prop = new MProperties(); prop.put("id", id); DbStatement sta = con.createStatement("SELECT content_ FROM " + prefix + "_node_ WHERE id_=$id$"); DbResult res = sta.executeQuery(prop); if (res.next()) { InputStream in = res.getBinaryStream("content_"); node = new PNode(); try { node.readExternal(new ObjectInputStream(in)); } catch (java.io.EOFException eofe) { log().w(node,eofe); // most because of extended parameters } } res.close(); con.close(); } catch (Exception e) { throw new IOException(e); } if (node == null) throw new NotFoundException("node",id); return node; }