Skip to content

Commit

Permalink
version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
donatellosantoro committed Nov 9, 2015
1 parent 785fa78 commit c365b46
Show file tree
Hide file tree
Showing 63 changed files with 612 additions and 630 deletions.
2 changes: 1 addition & 1 deletion LunaticGUI/commons/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
OpenIDE-Module: it.unibas.lunatic
OpenIDE-Module-Localizing-Bundle: it/unibas/lunatic/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
OpenIDE-Module-Specification-Version: 1.0.1
AutoUpdate-Essential-Module: true
1 change: 1 addition & 0 deletions LunaticGUI/commons/src/it/unibas/lunatic/BeansModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public boolean remove(String s, Object o) {
}

@Override
@SuppressWarnings("rawtypes")
public void notifyChange(String key, Class beanClass) {
impl.notifyChange(key, beanClass);
}
Expand Down
1 change: 1 addition & 0 deletions LunaticGUI/commons/src/it/unibas/lunatic/IModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface IModel {

boolean remove(String s, Object o);

@SuppressWarnings("rawtypes")
public void notifyChange(String key, Class beanClass);

String getName();
Expand Down
5 changes: 3 additions & 2 deletions LunaticGUI/commons/src/it/unibas/lunatic/ITaskListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import javax.swing.SwingWorker;

public interface ITaskListener<Task extends SwingWorker>{
@SuppressWarnings("rawtypes")
public interface ITaskListener<Task extends SwingWorker> {

public void onTaskStarted(Task task);

public void onTaskCompleted(Task task);

public void onTaskKilled(Task task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public IModelImpl createModel(String name) {
}

@Override
@SuppressWarnings("rawtypes")
public void notifyChange(String key, Class beanClass) {
EventObject ev = new AppModelChangeEvent(this, key, beanClass);
logger.trace(ev.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.unibas.lunatic.impl.EventBusApplication;
import java.util.EventObject;

@SuppressWarnings("rawtypes")
public class AppModelChangeEvent extends EventObject {

private final String beanName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import it.unibas.lunatic.IModel;
import java.util.EventObject;

@SuppressWarnings("rawtypes")
public class BeanModelChangeEvent extends EventObject {

private final String beanName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public EventBusModel(String name, EventBus bus) {
}

@Override
@SuppressWarnings("rawtypes")
public void notifyChange(String bean, Class beanClass) {
EventObject ev = new BeanModelChangeEvent(this, name, bean, beanClass);
logger.trace(ev.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public boolean remove(String s, Object o) {
}

@Override
@SuppressWarnings("rawtypes")
public void notifyChange(String key, Class beanClass) {
model.notifyChange(key, beanClass);
}
Expand All @@ -56,6 +57,7 @@ public Model(String name) {
}

@Override
@SuppressWarnings("rawtypes")
public void notifyChange(String key, Class type) {
setChanged();
notifyObservers(key);
Expand Down
14 changes: 7 additions & 7 deletions LunaticGUI/gui/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
keystore=../lunatic.ks
nbm.needs.restart=true
nbm_alias=lunatic-essentials
spec.version.base=1.0
storepass=lunatictest
javac.source=1.6
javac.compilerargs=-Xlint -Xlint:-serial
keystore=../lunatic.ks
nbm.needs.restart=true
nbm_alias=lunatic-essentials
spec.version.base=1.1
storepass=lunatictest
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import it.unibas.lunatic.IModel;
import it.unibas.lunatic.gui.R;
import it.unibas.lunatic.core.CellGroupHelper;
import it.unibas.lunatic.core.DbExtractor;
import it.unibas.lunatic.gui.node.TableNode;
import it.unibas.lunatic.gui.node.cellgroup.StepCellGroupNode;
import it.unibas.lunatic.gui.node.chase.mc.ChaseStepNode;
Expand Down Expand Up @@ -40,6 +41,7 @@ public final class ActionEditSelectedCellGroup extends ContextAwareActionProxy<S
private CellGroupHelper cgHelper = CellGroupHelper.getInstance();
private TableWindowManager tableWindowManager = TableWindowManager.getInstance();
private TableFinder tableFinder = new TableFinder();
private DbExtractor dbHelper = new DbExtractor();

public ActionEditSelectedCellGroup() {
putValue(NAME, Bundle.CTL_ActionEditSelectedCellGroup());
Expand All @@ -62,6 +64,7 @@ public void actionPerformed(ActionEvent ev) {
StepCellGroupNode editableCellGroupNode = getBean();
CellGroup cellGroup = editor.addChange(editableCellGroupNode.getChaseStep(), editableCellGroupNode.getCellGroup(), new ConstantValue(value), editableCellGroupNode.getChaseStep().getScenario());
editableCellGroupNode.setUserCellGroup(cellGroup);
dbHelper.extractDb(userNode.getChaseStep());
logger.debug("Edited cellGroup: " + editableCellGroupNode.toString());
getModel().notifyChange(R.BeanProperty.SELECTED_CELL_GROUP_NODE, editableCellGroupNode.getClass());
updateOpenedTables(userNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
import it.unibas.lunatic.gui.action.chase.task.InteractiveChase;
import it.unibas.lunatic.gui.model.IChaseResult;
import it.unibas.lunatic.gui.model.LoadedScenario;
import it.unibas.lunatic.gui.model.McChaseResult;
import it.unibas.lunatic.model.chase.chasemc.ChaseTree;
import it.unibas.lunatic.model.chase.chasemc.DeltaChaseStep;
import it.unibas.lunatic.model.chase.chasemc.usermanager.StandardUserManager;
import it.unibas.lunatic.model.chase.commons.ChaseUtility;
import it.unibas.lunatic.model.chase.commons.control.ChaseState;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.Action;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
Expand Down Expand Up @@ -58,14 +64,55 @@ public void actionPerformed(ActionEvent ev) {
@Override
public void onChange(IModel model, ChaseState chaseState) {
LoadedScenario scenario = (LoadedScenario) model;
if (scenario != null
&& scenario.get(R.BeanProperty.CHASE_STATE, ChaseState.class) == null
&& scenario.getScenario().isMCScenario()
&& scenario.get(R.BeanProperty.CHASE_RESULT, IChaseResult.class) != null
&& scenario.getScenario().getUserManager() != null) {
setEnabled(true);
} else {
setEnabled(false);
boolean isInteractive = isInteractive(scenario);
setEnabled(isInteractive);
}

private boolean isInteractive(LoadedScenario loadedScenario) {
if (loadedScenario == null || !loadedScenario.getScenario().isMCScenario()) {
if (logger.isDebugEnabled()) logger.debug("## MCScenario not loaded [Interactive FALSE]");
return false;
}
if (loadedScenario.get(R.BeanProperty.CHASE_STATE, ChaseState.class) != null) {
if (logger.isDebugEnabled()) logger.debug("## Scenario is running [Interactive FALSE]");
return false;
}
if (loadedScenario.get(R.BeanProperty.CHASE_RESULT, IChaseResult.class) == null) {
if (logger.isDebugEnabled()) logger.debug("## Scenario not yet executed [Interactive FALSE]");
return false;
}
if (loadedScenario.getScenario().getUserManager() != null && !(loadedScenario.getScenario().getUserManager() instanceof StandardUserManager)) {
if (logger.isDebugEnabled()) logger.debug("## Scenario has user manager [Interactive TRUE]");
return true;
}
ChaseTree chaseTree = loadedScenario.get(R.BeanProperty.CHASE_RESULT, McChaseResult.class).getResult();
return leaveAreUserNodes(chaseTree.getRoot());
}

private boolean leaveAreUserNodes(DeltaChaseStep root) {
if (root == null) {
return false;
}
List<DeltaChaseStep> leaves = ChaseUtility.getAllLeaves(root);
if (logger.isDebugEnabled()) logger.debug("## Leaves: " + leaves.size());
for (DeltaChaseStep leave : leaves) {
if (leave.isEditedByUser()) {
if (logger.isDebugEnabled()) logger.debug("## Scenario has user node [Interactive TRUE]");
return true;
}
}
if (logger.isDebugEnabled()) logger.debug("## Scenario has no user node [Interactive FALSE]");
return false;
}
// @Override
// public void onChange(IModel model, ChaseState chaseState) {
// LoadedScenario scenario = (LoadedScenario) model;
// if (scenario != null
// && scenario.get(R.BeanProperty.CHASE_STATE, ChaseState.class) == null
// && scenario.getScenario().isMCScenario()
// && scenario.get(R.BeanProperty.CHASE_RESULT, IChaseResult.class) != null
// && scenario.getScenario().getUserManager() != null) {
// setEnabled(true);
// }
// }
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package it.unibas.lunatic.gui.action.chase;

import it.unibas.lunatic.ContextAwareActionProxy;
import it.unibas.lunatic.IModel;
import it.unibas.lunatic.OperatorFactory;
import it.unibas.lunatic.Scenario;
import it.unibas.lunatic.core.DbExtractor;
import it.unibas.lunatic.gui.R;
import it.unibas.lunatic.gui.action.chase.task.ChaseTaskListener;
import it.unibas.lunatic.gui.model.LoadedScenario;
import it.unibas.lunatic.gui.node.chase.mc.ChaseStepNode;
import it.unibas.lunatic.model.chase.chasemc.DeltaChaseStep;
import it.unibas.lunatic.model.chase.chasemc.operators.AddUserNode;
import it.unibas.lunatic.model.chase.commons.control.ChaseState;
import it.unibas.lunatic.model.chase.commons.control.IChaseState;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.DialogDisplayer;
Expand All @@ -23,15 +30,15 @@
@Messages({
"CTL_ActionCreateUserNode=Create user node",
"MSG_UserNodeLimit=This step already has a user node",
"MSG_InvalidParent=An invalid step cannot have a user node",
})
public final class ActionCreateUserNode implements ActionListener {
"MSG_InvalidParent=An invalid step cannot have a user node",})
public final class ActionCreateUserNode extends ContextAwareActionProxy<ChaseState> implements ActionListener {
//public final class ActionCreateUserNode implements ActionListener {

private NotifyDescriptor.Message limitDialog = new NotifyDescriptor.Message(Bundle.MSG_UserNodeLimit());
private NotifyDescriptor.Message invalidDialog = new NotifyDescriptor.Message(Bundle.MSG_InvalidParent());
private DialogDisplayer dialogDisplayer = DialogDisplayer.getDefault();
private final ChaseStepNode context;
private OperatorFactory operatorFactory = OperatorFactory.getInstance();
private final ChaseStepNode context;

public ActionCreateUserNode(ChaseStepNode context) {
this.context = context;
Expand All @@ -48,6 +55,10 @@ public void actionPerformed(ActionEvent ev) {
AddUserNode addUserNode = operatorFactory.getUserNodeCreator(scenario);
DeltaChaseStep userChaseStep = addUserNode.addUserNode(context.getChaseStep(), scenario);
context.addUserNode(userChaseStep);
context.refreshCellGroups();
LoadedScenario loadedScenario = app.get(R.Bean.LOADED_SCENARIO, LoadedScenario.class);
loadedScenario.put(R.BeanProperty.CHASE_STATE, new ChaseState());
loadedScenario.remove(R.BeanProperty.CHASE_STATE);
}
}

Expand All @@ -62,4 +73,13 @@ private boolean hasUserNode(ChaseStepNode context) {
}
return false;
}

@Override
protected void register() {
super.registerBean(R.Bean.LOADED_SCENARIO, R.BeanProperty.CHASE_STATE, ChaseState.class);
}

@Override
public void onChange(IModel model, ChaseState bean) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import it.unibas.lunatic.gui.R;
import it.unibas.lunatic.gui.model.IChaseResult;
import it.unibas.lunatic.gui.model.LoadedScenario;
import it.unibas.lunatic.model.chase.commons.ChaseStats;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
Expand All @@ -24,7 +25,7 @@

@NbBundle.Messages({
"MSG_ChaseScenario=Scenario chase in progress",
"MSG_ChaseSuccessful=Chase successful",
"MSG_ChaseSuccessful=Chase complete",
"MSG_ChaseFailed=Chase failed",
"MSG_ChaseStopping=stopping ",
"MSG_ChaseCancelled=Chase cancelled",
Expand Down Expand Up @@ -55,7 +56,12 @@ public void onTaskCompleted(ChaseTask task) {
IChaseResult result = task.get();
LoadedScenario scenario = task.getScenario();
scenario.put(R.BeanProperty.CHASE_RESULT, result);
status.setStatusText(Bundle.MSG_ChaseSuccessful());
String statusText = Bundle.MSG_ChaseSuccessful();
Long exTime = ChaseStats.getInstance().getStat(ChaseStats.TOTAL_TIME);
if (exTime != null && exTime > 0) {
statusText += " in " + exTime + " ms";
}
status.setStatusText(statusText);
for (String windowName : result.getWindowsToOpen()) {
view.show(windowName);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import it.unibas.lunatic.model.chase.chasemc.ChaseTree;
import it.unibas.lunatic.model.chase.chasemc.DeltaChaseStep;
import it.unibas.lunatic.model.chase.chasemc.operators.ChaseMCScenario;
import it.unibas.lunatic.model.chase.chasemc.operators.PrintRankedSolutions;
import it.unibas.lunatic.model.chase.chasemc.operators.RankSolutions;
import it.unibas.lunatic.model.chase.commons.ChaseUtility;
import it.unibas.lunatic.model.chase.commons.ChaserFactory;
Expand All @@ -16,6 +17,7 @@
public class InteractiveChase implements IChaseOperator {

private final RankSolutions solutionRanker = new RankSolutions();
private final PrintRankedSolutions solutionPrinter = new PrintRankedSolutions();

@Override
public IChaseResult chase(LoadedScenario loadedScenario) {
Expand All @@ -28,6 +30,7 @@ public IChaseResult chase(LoadedScenario loadedScenario) {
chaseTree.setRoot(newRoot);
if (ChaseUtility.hasChaseStats(scenario)) {
solutionRanker.rankSolutions(chaseTree);
System.out.println(solutionPrinter.toString(chaseTree));
}
return new McChaseResult(loadedScenario, chaseTree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@
import it.unibas.lunatic.gui.model.McChaseResult;
import it.unibas.lunatic.model.chase.chasede.DEChaserFactory;
import it.unibas.lunatic.model.chase.chasede.IDEChaser;
import it.unibas.lunatic.model.chase.chaseded.DEDChaserFactory;
import it.unibas.lunatic.model.chase.chasemc.ChaseTree;
import it.unibas.lunatic.model.chase.chasemc.operators.CellGroupIDGenerator;
import it.unibas.lunatic.model.chase.chasemc.operators.ChaseMCScenario;
import it.unibas.lunatic.model.chase.commons.ChaseStats;
import speedy.model.database.IDatabase;
import it.unibas.lunatic.model.chase.commons.ChaserFactory;
import it.unibas.lunatic.model.chase.commons.control.IChaseState;
import it.unibas.lunatic.persistence.relational.LunaticDBMSUtility;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import speedy.model.database.dbms.DBMSDB;
import speedy.model.database.mainmemory.datasource.IntegerOIDGenerator;
import speedy.model.database.operators.IDatabaseManager;
import speedy.model.database.operators.dbms.SQLDatabaseManager;
import speedy.persistence.relational.QueryStatManager;
import speedy.utility.DBMSUtility;

public class StandardChase implements IChaseOperator {

Expand All @@ -32,7 +37,9 @@ public IChaseResult chase(LoadedScenario loadedScenario) {
IChaseState chaseState = loadedScenario.get(R.BeanProperty.CHASE_STATE, IChaseState.class);
if (logger.isDebugEnabled()) logger.debug("Executing chase with configuration\n" + loadedScenario.getScenario().getConfiguration());
IChaseResult result;
if (loadedScenario.getScenario().isDEScenario()) {
if (loadedScenario.getScenario().isDEDScenario()) {
result = chaseDEDScenario(loadedScenario, chaseState);
} else if (loadedScenario.getScenario().isDEScenario()) {
result = chaseDEScenario(loadedScenario, chaseState);
} else {
result = chaseMCScenario(loadedScenario, chaseState);
Expand All @@ -47,6 +54,12 @@ private IChaseResult chaseDEScenario(LoadedScenario ls, IChaseState chaseState)
return new DeChaseResult(ls, result);
}

private IChaseResult chaseDEDScenario(LoadedScenario loadedScenario, IChaseState chaseState) {
Scenario scenario = loadedScenario.getScenario();
IDatabase result = DEDChaserFactory.getChaser(scenario).doChase(scenario, chaseState);
return new DeChaseResult(loadedScenario, result);
}

private IChaseResult chaseMCScenario(LoadedScenario ls, IChaseState chaseState) {
Scenario scenario = ls.getScenario();
ChaseMCScenario chaser = ChaserFactory.getChaser(scenario);
Expand All @@ -68,5 +81,15 @@ private void reset(LoadedScenario loadedScenario) {
if (scenario.getTarget() instanceof DBMSDB) {
((DBMSDB) scenario.getTarget()).reset();
}
if (scenario.isDBMS() && !scenario.getSTTgds().isEmpty()) {
//Scenario has STTGDs. Need to clean target in order to avoid interaction btw sequential runs
if (logger.isDebugEnabled()) logger.debug("Cleaning target");
DBMSDB source = (DBMSDB) scenario.getSource();
DBMSDB target = (DBMSDB) scenario.getTarget();
DBMSUtility.removeSchema(target.getAccessConfiguration().getSchemaName(), source.getAccessConfiguration());
target.reset();
target.initDBMS();

}
}
}
Loading

0 comments on commit c365b46

Please sign in to comment.