|
From: Miguel V. F. <mv...@us...> - 2001-03-26 09:50:40
|
Update of /cvsroot/motu/heroine/src/hero/project
In directory usw-pr-cvs1:/tmp/cvs-serv11427/src/hero/project
Modified Files:
ProjectHome.java
Added Files:
Edge.java Node.java
Log Message:
--- NEW FILE ---
package hero.project;
import java.sql.*;
import javax.sql.*;
import java.rmi.RemoteException;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
public class Edge {
public static final int INITIAL = 0;
Connection dbConnection = null;
// Edge constants
//public static final int INITIAL = 0;
public static final int ACTIVE = 1;
public static final int ANTICIPATING = 2;
public static final int DEAD = 3;
// Node atributes
private String edgeName;
private String edgeCreator;
private String edgeState;
private String edgeNodeIn;
private String edgeNodeOut;
public void Edge() {};
/**
* Method that obtain edge instance
*/
public Edge getEdge(String name, ProjectEJB project) {
try {
findEdge(name, project);
}catch(Exception findEdge){};
return(this);
}
/**
* Method that obtain edgeName value
*/
public String getEdgeeName() {
return edgeName;
}
/**
* Method that obtain edgeCreator value
*/
public String getEdgeCreator() {
return edgeCreator;
}
/**
* Method that obtain edgeState value
*/
public String getEdgeState() {
return edgeState;
}
/**
* Inserts the Entity state into database,
* Initializes the instance variables
* and returns the primary key.
*/
public String createEdge (String edgeName, String edgeCreator, String edgeState, ProjectEJB edgeProject, String edgeNodeIn, String edgeNodeOut)
throws DuplicateKeyException,CreateException {
ProjectDAO ADAO = new ProjectDAO();
ADAO.setEdgeName(edgeName);
ADAO.setEdgeCreator(edgeCreator);
ADAO.setEdgeState(edgeState);
ADAO.setEdgeNodeIn(edgeNodeIn);
ADAO.setEdgeNodeOut(edgeNodeOut);
try{
dbConnection = edgeProject.getDBConnection();
ADAO.createEdge(dbConnection);
return (edgeName);
}catch (java.sql.SQLException se) {
throw new CreateException ("SQL Exception in create:" + se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new CreateException
("SQL Exception in create:" + se);
}
}
}
/**
* Finder method that obtain edge fields for specific edgeName
*/
public void findEdge (String name, ProjectEJB edgeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
ADAO.setEdgeName(name);
try{
dbConnection = edgeProject.getDBConnection();
if (ADAO.findByEdgeName(dbConnection) == true)
{
this.edgeName = ADAO.getEdgeName();
this.edgeCreator = ADAO.getEdgeCreator();
this.edgeState = ADAO.getEdgeState();
this.edgeNodeIn = ADAO.getEdgeNodeIn();
this.edgeNodeOut = ADAO.getEdgeNodeOut();
}
}catch (java.sql.SQLException se) {
throw new FinderException ("SQL Exception in find by primary key");
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new FinderException ("SQL Exception in find by primary key");
}
}
}
/**
* Store method that set edge information
*/
public void storeEdge (ProjectEJB edgeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
try{
dbConnection = edgeProject.getDBConnection();
ADAO.setEdgeName(this.edgeName);
ADAO.setEdgeCreator(this.edgeCreator);
ADAO.setEdgeState(this.edgeState);
ADAO.setEdgeNodeIn(this.edgeNodeIn);
ADAO.setEdgeNodeOut(this.edgeNodeOut);
ADAO.storeEdgeRow(dbConnection);
}catch (java.sql.SQLException se) {
throw new EJBException (se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new EJBException (se);
}
}
}
/**
* Delete edge
*/
public void deleteEdge (ProjectEJB edgeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
try{
dbConnection = edgeProject.getDBConnection();
ADAO.setEdgeName(this.edgeName);
ADAO.deleteEdgeRow(dbConnection);
}catch (java.sql.SQLException se) {
throw new EJBException (se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new EJBException (se);
}
}
}
}
--- NEW FILE ---
package hero.project;
import java.sql.*;
import javax.sql.*;
import java.util.*;
import java.rmi.RemoteException;
import javax.ejb.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class Node {
public static final int INITIAL = 0;
Connection dbConnection = null;
// Node constants
public static final int READY = 1;
public static final int DEAD = 2;
public static final int ANTICIPABLE = 3;
public static final int EXPIRED = 4;
public static final int ANTICIPATING = 5;
public static final int EXECUTING = 6;
public static final int EXECUTED = 7;
public static final int INERROR = 8;
public static final int FINISHED = 9;
public static final int TERMINATED = 10;
public static final int CHECKEDOUT = 11;
public static final int SUSPENDED = 12;
// Node atributes
private String nodeName;
private String nodeCreator;
private String nodeState;
public void Node() {};
/**
* Method that obtain node instance
*/
public Node getNode(String name, ProjectEJB project) {
try {
findNode(name, project);
}catch(Exception findEdge){};
return(this);
}
/**
* Method that obtain nodeName value
*/
public String getNodeName() {
return nodeName;
}
/**
* Method that obtain nodeCreator value
*/
public String getNodeCreator() {
return nodeCreator;
}
/**
* Method that obtain nodeState value
*/
public String getNodeState() {
return nodeState;
}
/**
* Inserts the Entity state into database,
* Initializes the instance variables
* and returns the primary key.
*/
public String createNode (String nodeName, String nodeCreator, String nodeState, ProjectEJB nodeProject) throws DuplicateKeyException,CreateException {
ProjectDAO ADAO = new ProjectDAO();
ADAO.setNodeName(nodeName);
ADAO.setNodeCreator(nodeCreator);
ADAO.setNodeState(nodeState);
try{
dbConnection = nodeProject.getDBConnection();
ADAO.createNode(dbConnection);
return (nodeName);
}catch (java.sql.SQLException se) {
throw new CreateException ("SQL Exception in create:" + se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new CreateException
("SQL Exception in create:" + se);
}
}
}
/**
* Finder method that obtain node fields for specific nodeName
*/
public void findNode (String name, ProjectEJB nodeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
ADAO.setNodeName(name);
try{
dbConnection = nodeProject.getDBConnection();
if (ADAO.findByNodeName(dbConnection) == true)
{
this.nodeName = ADAO.getNodeName();
this.nodeCreator = ADAO.getNodeCreator();
this.nodeState = ADAO.getNodeState();
}
}catch (java.sql.SQLException se) {
throw new FinderException ("SQL Exception in find by primary key");
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new FinderException ("SQL Exception in find by primary key");
}
}
}
/**
* Store method that set node information
*/
public void storeNode (ProjectEJB nodeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
try{
dbConnection = nodeProject.getDBConnection();
ADAO.setNodeName(this.nodeName);
ADAO.setNodeCreator(this.nodeCreator);
ADAO.setNodeState(this.nodeState);
ADAO.storeNodeRow(dbConnection);
}catch (java.sql.SQLException se) {
throw new EJBException (se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new EJBException (se);
}
}
}
/**
* Delete node
*/
public void deleteNode (ProjectEJB nodeProject) throws FinderException {
ProjectDAO ADAO = new ProjectDAO();
try{
dbConnection = nodeProject.getDBConnection();
ADAO.setNodeName(this.nodeName);
ADAO.deleteNodeRow(dbConnection);
}catch (java.sql.SQLException se) {
throw new EJBException (se);
} finally {
try {
dbConnection.close();
} catch (SQLException se) {
throw new EJBException (se);
}
}
}
}
Index: ProjectHome.java
===================================================================
RCS file: /cvsroot/motu/heroine/src/hero/project/ProjectHome.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ProjectHome.java 2001/03/22 15:48:23 1.3
--- ProjectHome.java 2001/03/26 09:50:35 1.4
***************
*** 13,17 ****
*/
public Project create(java.lang.String projectName, java.lang.String projectCreator)
! throws RemoteException, CreateException;
/**
--- 13,17 ----
*/
public Project create(java.lang.String projectName, java.lang.String projectCreator)
! throws DuplicateKeyException, CreateException;
/**
|