Some more work on Triggers. issue 6
This commit is contained in:
parent
36f2509d94
commit
5170a151c8
7 changed files with 26 additions and 29 deletions
|
|
@ -94,7 +94,7 @@
|
|||
|
||||
<target name="build-dependencies">
|
||||
<mkdir dir="${buildDir}" />
|
||||
<get src="http://ci.koc.se/jenkins/job/Zutil/136/artifact/build/release/Zutil.jar"
|
||||
<get src="http://ci.koc.se/jenkins/job/Zutil/137/artifact/build/release/Zutil.jar"
|
||||
dest="${libDir}" verbose="true" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
|
|
|
|||
BIN
hal-default.db
BIN
hal-default.db
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
package se.hal.trigger.action;
|
||||
package se.hal.action;
|
||||
|
||||
import se.hal.ControllerManager;
|
||||
import se.hal.HalContext;
|
||||
|
|
@ -9,7 +9,6 @@ import zutil.db.DBConnection;
|
|||
import zutil.log.LogUtil;
|
||||
import zutil.ui.Configurator;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ public class TriggerHttpPage extends HalHttpPage {
|
|||
case "modify_trigger":
|
||||
trigger.setObjectClass(request.get("type"));
|
||||
trigger.getObjectConfigurator().setValues(request).applyConfiguration();
|
||||
trigger.save(db);
|
||||
flow.save(db); // will save all sub beans also
|
||||
break;
|
||||
case "remove_trigger":
|
||||
flow.removeTrigger(trigger);
|
||||
|
|
@ -99,7 +99,7 @@ public class TriggerHttpPage extends HalHttpPage {
|
|||
case "modify_action":
|
||||
action.setObjectClass(request.get("type"));
|
||||
action.getObjectConfigurator().setValues(request).applyConfiguration();
|
||||
action.save(db);
|
||||
flow.save(db); // will save all sub beans also
|
||||
break;
|
||||
case "remove_action":
|
||||
flow.removeAction(action);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import se.hal.intf.HalTrigger;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBeanObjectDSO;
|
||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -20,9 +22,10 @@ public class Action extends DBBeanObjectDSO<HalAction>{
|
|||
public static Action getAction(DBConnection db, long id) throws SQLException {
|
||||
return DBBean.load(db, Action.class, id);
|
||||
}
|
||||
public static List<Action> getActions(DBConnection db, TriggerFlow flow) {
|
||||
// TODO:
|
||||
return new ArrayList<>();
|
||||
public static List<Action> getActions(DBConnection db, TriggerFlow flow) throws SQLException {
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM action WHERE flow_id == ?" );
|
||||
stmt.setLong(1, flow.getId());
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Action.class, db) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import se.hal.intf.HalTrigger;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBeanObjectDSO;
|
||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -21,9 +23,10 @@ public class Trigger extends DBBeanObjectDSO<HalTrigger>{
|
|||
public static Trigger getTrigger(DBConnection db, long id) throws SQLException {
|
||||
return DBBean.load(db, Trigger.class, id);
|
||||
}
|
||||
public static List<Trigger> getTriggers(DBConnection db, TriggerFlow flow) {
|
||||
// Todo:
|
||||
return new ArrayList<>();
|
||||
public static List<Trigger> getTriggers(DBConnection db, TriggerFlow flow) throws SQLException {
|
||||
PreparedStatement stmt = db.getPreparedStatement( "SELECT * FROM trigger WHERE flow_id == ?" );
|
||||
stmt.setLong(1, flow.getId());
|
||||
return DBConnection.exec(stmt, DBBeanSQLResultHandler.createList(Trigger.class, db) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,14 @@
|
|||
package se.hal.struct;
|
||||
|
||||
import se.hal.HalContext;
|
||||
import se.hal.intf.HalAction;
|
||||
import se.hal.intf.HalTrigger;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.db.bean.DBBean;
|
||||
import zutil.db.bean.DBBeanSQLResultHandler;
|
||||
import zutil.log.LogUtil;
|
||||
import zutil.parser.DataNode;
|
||||
import zutil.parser.json.JSONParser;
|
||||
import zutil.parser.json.JSONWriter;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
|
|
@ -26,8 +19,10 @@ import java.util.logging.Logger;
|
|||
public class TriggerFlow extends DBBean {
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
|
||||
private transient List<Trigger> triggerList = new ArrayList<>();
|
||||
private transient List<Action> actionList = new ArrayList<>();
|
||||
@DBLinkTable(beanClass=Trigger.class, table="trigger", idColumn = "flow_id")
|
||||
private List<Trigger> triggerList = new ArrayList<>();
|
||||
@DBLinkTable(beanClass=Action.class, table="action", idColumn = "flow_id")
|
||||
private List<Action> actionList = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
|
|
@ -40,16 +35,13 @@ public class TriggerFlow extends DBBean {
|
|||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void postUpdateAction() {
|
||||
DBConnection db = HalContext.getDB();
|
||||
|
||||
triggerList.clear();
|
||||
triggerList = Trigger.getTriggers(db, this);
|
||||
|
||||
actionList.clear();
|
||||
actionList = Action.getActions(db, this);
|
||||
public void delete(DBConnection db) throws SQLException {
|
||||
for(Trigger trigger : triggerList)
|
||||
trigger.delete(db);
|
||||
for(Action action : actionList)
|
||||
action.delete(db);
|
||||
super.delete(db);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue