Push changes for Angel

master
Chloe Fontenot 🏳️‍⚧️ 2024-02-23 20:26:59 +07:00
parent e74ed9dbca
commit e342f849ef
31 changed files with 1777 additions and 8 deletions

1
.gitignore vendored

@ -91,3 +91,4 @@
/Semester 3/Assignments/mavenproject1/target/
/Semester 3/Assignments/Templates01_CalebFontenot/target/
/Semester 3/Assignments/MaxTask/target/
/Semester 3/Assignments/MP1_Ajax/target/

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>10-web</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv700ee10</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
<org-netbeans-modules-projectapi.jsf_2e_language>JSP</org-netbeans-modules-projectapi.jsf_2e_language>
<netbeans.hint.jdkPlatform>JDK_15__System_</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>

@ -0,0 +1,125 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>asdv</groupId>
<artifactId>MP1_Ajax</artifactId>
<version>1</version>
<packaging>war</packaging>
<name>MP1_Ajax-1</name>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>10.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>13.0.2</version>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.asm</artifactId>
<version>9.4.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.antlr</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.jpql</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.12</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>jakarta.persistence</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,25 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
*/
import asdv.mp1_ajax.pojos.Stock;
import java.util.List;
/**
*
* @author asdv5
*/
public interface Dao<T>
{
void create(T t);
void edit(T t);
void remove(T t);
T find(Object id);
List<T> findAll();
List<T> findRange(int[] range);
int count();
}

@ -0,0 +1,13 @@
package asdv.mp1_ajax;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;
/**
* Configures Jakarta RESTful Web Services for the application.
* @author Juneau
*/
@ApplicationPath("resources")
public class JakartaRestConfiguration extends Application {
}

@ -0,0 +1,109 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import java.util.List;
import java.util.Set;
/**
*
* @author A. V. Markou
* @param <Many1>
* @param <Many2>
*/
public interface ManyToMany<Many1, Many2>
{
/**
* Creates a Many to Many relationship between the parentLeft and the
* childrenRight. Example for ( Many1 a, Many2 1, 2, 3) it creates --> (a 1)
* ( a 2 ) ( a 3 ) and ( 1, a ), ( 2, a ), ( 3, a). No duplicate values of
* Many2 are allowed.
*
* @param parentLeft - exactly one Many1 object.
* @param childrenRight - one or more Many2 objects.
* @return the previous value associated with Many1, or null if there was no
* Many1 with the same "key".
* @throws ClassCastException - if the class of the specified Many1, or
* Many2 or value prevents it from being stored in this map( i,e Many1 is
* String and you pass an object)
* @throws NullPointerException - if the specified Many1 or Many2 is null
* and ManyToMany does not permit nulls as values.
* @throw IllegalArgumentException - if a duplicate exists in childrenRight
* list ( s1 --> p1,p2,p2 is not allowed).
* @return the previous value associated with parentLeft, or null if there
* was no childrenRight for parentLeft.
*/
List<Many2> add(Many1 parentLeft, Many2... childrenRight);
/**
* Returns the List of all left children of the parentRight.
*
* @param parentRight a parent at the RHS of the many to many relationship.
* @return the List of all left children of the parentRight.
* @throw IllegalArgumentException if the value of parameter parentRight
* does not exist in the RHS of the many to many relationship.
*/
List<Many1> getChildrenLeft(Many2 parentRight);
/**
* Returns the List of all right children of the parentLeft.
*
* @param parentLeft a parent at the LHS of the many to many relationship.
* @return the List of all right children of the parentLeft.
* @throws IllegalArgumentException if the value of parameter parentLeft
* does not exist on the LHS of the many to many relationship.
*/
List<Many2> getChildrenRight(Many1 parentLeft);
/**
* Returns a set of the Many1 elements that exist on the LHS of the many to
* many relationship.
*
* @return Set of Many1
*/
Set<Many1> getParentsLeft();
/**
* Returns a set of the Many2 elements that exist on the RHS of the many to
* many relationship.
*
* @return Set of Many2
*/
Set<Many2> getParentsRight();
/**
* Removes the many1 parameter from the LHS of the many relationship AND all
* its corresponding values that exist in the RHS of the many to many
* relationship. For example given: ( LHS e1: p1, p2 e2: p2, p3 RHS: p1: e1
* p2: e1, e2 p3: e2 after removing e1 from the LHS will results into: ( LHS
* e2: p2, p3 RHS: p2: e2 p3: e2
*
* @param many1 the unique element on the LHS to be removed.
* @throws NullPointerException if parameter many1 is null.
* @return true if the removal occurred, false if many1 does not exist in
* the LHS of the many to many relationship.
*/
boolean removeLeft(Many1 many1);
/**
* Removes the many1 parameter from the RHS of the many relationship AND all
* its corresponding values that exist in the LHS of the many to many
* relationship. For example given: LHS e2: p2, p3 RHS: p2: e2 p3: e2 after
* removing p2 from the RHS will results into: LHS e2: p3 RHS p3: e2
*
*
* @param many2 the unique element on the LHS to be removed.
* @throws NullPointerException if parameter many1 is null.
* @return true if the removal occurred, false if many1 does not exist in
* the LHS of the many to many relationship.
*/
boolean removeRight(Many2 many2);
/**
* Clears all.
*
*/
void clear();
}

@ -0,0 +1,212 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import asdv.mp1_ajax.pojos.ManyToMany;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
* @author asdv5
*/
public class ManyToManyFactory1
{
public static <Many1, Many2> //generic types to be used in the method
ManyToMany< Many1, Many2>//return type
createManyToMany()
{
return new ManyToMany<Many1, Many2>()
{
private Map<Object, Object> left = new HashMap();
private Map<Object, Object> right = new HashMap();
@Override
public String toString()
{
return "{" + "left=" + left + ", right=" + right + '}';
}
@Override
public List<Many2> add(Many1 parentLeft, Many2... childrenRight)
{
if (parentLeft==null || childrenRight==null || getParentsLeft().contains(parentLeft)) {
throw new IllegalArgumentException("Invalid input: null arguments or duplicate parent");
}
left.put(parentLeft, Arrays.asList(childrenRight));
for(Many2 parentRight : childrenRight)
{
right.put(parentRight, Arrays.asList(parentLeft));
}
return Arrays.asList(childrenRight);
}
@Override
public List<Many1> getChildrenLeft(Many2 parentRight)
{
if(right.get(parentRight)==null)
{
throw new IllegalArgumentException(parentRight+" is not a valid R parent");
}
return (List<Many1>) right.get(parentRight);
}
@Override
public List<Many2> getChildrenRight(Many1 parentLeft)
{
if(left.get(parentLeft)==null)
{
throw new IllegalArgumentException(parentLeft+" is not a valid L parent");
}
return (List<Many2>)left.get(parentLeft);
}
@Override
public Set<Many1> getParentsLeft()
{
return (Set<Many1>) left.keySet();
}
@Override
public Set<Many2> getParentsRight()
{
return (Set<Many2>) right.keySet();
}
@Override
public boolean removeLeft(Many1 many1)
{
if(!getParentsLeft().contains(many1))
{
return false;
}
left.remove(many1);
for(Many2 parentRight : getParentsRight())
{
right.remove(parentRight, many1);
}
return true;
}
@Override
public boolean removeRight(Many2 many2)
{
if(!getParentsRight().contains(many2))
{
return false;
}
right.remove(many2);
for(Many1 parentLeft : getParentsLeft())
{
left.remove(parentLeft, many2);
}
return true;
}
@Override
public void clear()
{
left.clear();
right.clear();
}
};
}
public static void main(String[] args) throws InterruptedException
{
ManyToMany<String, String> mm = ManyToManyFactory1.createManyToMany();
//mm.add(1, 1);///will not compile, we have Many1, Many2 as String
System.out.println("add(e1, p1, p2)returns: " + mm.add("e1", "p1", "p2"));
System.out.println("add(e2, p2, p3)returns: " + mm.add("e2", "p2", "p3"));
System.out.println("getParentsLeft returns: " + mm.getParentsLeft());
System.out.println("getParentsRight returns: " + mm.getParentsRight());
System.out.println("getChildrenLeft(p2) returns: " + mm.getChildrenLeft("p2"));
System.out.println("getChildrenLeft(p3) returns: " + mm.getChildrenLeft("p3"));
System.out.println("getChildrenRight(e1) returns: " + mm.getChildrenRight("e1"));
System.out.println("getChildrenRight(e2) returns: " + mm.getChildrenRight("e2"));
System.out.println("-----------------------------------------------");
System.out.println("The internal hash maps of ManyToMany after insertions: " + mm);
System.out.println("----------AFTER REMOVAL of e1 LEFT----------------------------------------");
System.out.println("removeLeft(e1) returns: " + mm.removeLeft("e1"));
System.out.println("getParentsLeft returns: " + mm.getParentsLeft());
System.out.println("getParentsRight returns: " + mm.getParentsRight());
System.out.println("getChildrenRight(e2) returns: " + mm.getChildrenRight("e2"));
System.out.println("getChildrenLeft(p2) returns: " + mm.getChildrenLeft("p2"));
System.out.println("getChildrenLeft(p3) returns: " + mm.getChildrenLeft("p3"));
System.out.println("The internal hash maps of ManyToMany after removal LEFT: " + mm);
System.out.println("\n----------AFTER REMOVAL of p2 RIGHT----------------------------------------");
System.out.println("removeRight(p2) returns: " + mm.removeRight("p2"));
System.out.println("getParentsLeft returns: " + mm.getParentsLeft());
System.out.println("getParentsRight returns: " + mm.getParentsRight());
System.out.println("getChildrenRight(e2) returns: " + mm.getChildrenRight("e2"));
System.out.println("getChildrenLeft(p3) returns: " + mm.getChildrenLeft("p3"));
System.out.println("--------------------------------------------------");
System.out.println("mm.removeLeft(e1) returns: " + mm.removeLeft("e1"));
System.out.println("The internal hash maps of ManyToMany after removal RIGHT: " + mm);
Thread.sleep(5000, 0);
System.out.println("---------------CATCHING EXCEPTIONS -----------------------------------");
try
{
mm.getChildrenRight("e10");//e10 dos not exist
}
catch (RuntimeException e)
{
System.err.println("getChildrenRight for e10 throws exception:" + e);
}
try
{
System.out.println(mm.add("e6", new String[]
{
"value1", null
}));
}
catch (RuntimeException e)
{
System.err.println("add(e6, new String[]{null } ) throws exception: " + e);
}
try
{
System.out.println(mm.add(null, "p1"));
}
catch (RuntimeException e)
{
System.err.println("add(null, p1)returns throws exception: " + e);
}
try
{
System.out.println(mm.getChildrenRight("p1"));
}
catch (RuntimeException e)
{
System.err.println("getChildrenRight(p1) throws exception: " + e);
}
try
{
mm.add((String) new Object(), (String) new Object());
}
catch (RuntimeException e)
{
System.err.println("add((String) new Object(), (String) new Object()) throws exception: " + e);
}
mm.clear();
System.out.println("-----------------------------------------------");
System.out.println("The internal hash maps of ManyToMany after clear: " + mm);
}
}

@ -0,0 +1,147 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import java.io.Serializable;
import java.util.Collection;
public class Stock implements Serializable
{
private static final long serialVersionUID = 1L;
private String stockId;
private String companyName;
private double priceCurrent;
private double priceClosing;
private long numberOfSharesAvailable;
private long numberOfSharesSold;
private Collection<Transactions> transactionsCollection;
public Stock()
{
}
public Stock(String stockId)
{
this.stockId = stockId;
}
public Stock(String stockId, String companyName, double priceCurrent, double priceClosing, long numberOfSharesAvailable, long numberOfSharesSold)
{
this.stockId = stockId;
this.companyName = companyName;
this.priceCurrent = priceCurrent;
this.priceClosing = priceClosing;
this.numberOfSharesAvailable = numberOfSharesAvailable;
this.numberOfSharesSold = numberOfSharesSold;
}
public String getStockId()
{
return stockId;
}
public void setStockId(String stockId)
{
this.stockId = stockId;
}
public String getCompanyName()
{
return companyName;
}
public void setCompanyName(String companyName)
{
this.companyName = companyName;
}
public double getPriceCurrent()
{
return priceCurrent;
}
public void setPriceCurrent(double priceCurrent)
{
this.priceCurrent = priceCurrent;
}
public double getPriceClosing()
{
return priceClosing;
}
public void setPriceClosing(double priceClosing)
{
this.priceClosing = priceClosing;
}
public long getNumberOfSharesAvailable()
{
return numberOfSharesAvailable;
}
public void setNumberOfSharesAvailable(long numberOfSharesAvailable)
{
this.numberOfSharesAvailable = numberOfSharesAvailable;
}
public long getNumberOfSharesSold()
{
return numberOfSharesSold;
}
public void setNumberOfSharesSold(long numberOfSharesSold)
{
this.numberOfSharesSold = numberOfSharesSold;
}
public Collection<Transactions> getTransactionsCollection()
{
return transactionsCollection;
}
public void setTransactionsCollection(Collection<Transactions> transactionsCollection)
{
this.transactionsCollection = transactionsCollection;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (stockId != null ? stockId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Stock))
{
return false;
}
Stock other = (Stock) object;
if ((this.stockId == null && other.stockId != null) || (this.stockId != null && !this.stockId.equals(other.stockId)))
{
return false;
}
return true;
}
@Override
public String toString()
{
return "asdv.mp1_ajax.entities.Stock[ stockId=" + stockId + " ]";
}
}

@ -0,0 +1,98 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import java.io.Serializable;
import java.util.Collection;
public class StockHolder implements Serializable
{
private static final long serialVersionUID = 1L;
private Integer stockHolderId;
private String name;
//cascade
private Collection<Transactions> transactionsCollection;
public StockHolder()
{
}
public StockHolder(Integer stockHolderId)
{
this.stockHolderId = stockHolderId;
}
public StockHolder(Integer stockHolderId, String name)
{
this.stockHolderId = stockHolderId;
this.name = name;
}
public Integer getStockHolderId()
{
return stockHolderId;
}
public void setStockHolderId(Integer stockHolderId)
{
this.stockHolderId = stockHolderId;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Collection<Transactions> getTransactionsCollection()
{
return transactionsCollection;
}
public void setTransactionsCollection(Collection<Transactions> transactionsCollection)
{
this.transactionsCollection = transactionsCollection;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (stockHolderId != null ? stockHolderId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof StockHolder))
{
return false;
}
StockHolder other = (StockHolder) object;
if ((this.stockHolderId == null && other.stockHolderId != null) || (this.stockHolderId != null && !this.stockHolderId.equals(other.stockHolderId)))
{
return false;
}
return true;
}
@Override
public String toString()
{
return "asdv.mp1_ajax.entities.StockHolder[ stockHolderId=" + stockHolderId + " ]";
}
}

@ -0,0 +1,112 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import java.io.Serializable;
public class Transactions implements Serializable
{
private static final long serialVersionUID = 1L;
protected TransactionsPK transactionsPK;
private int qty;
private Stock stock;
private StockHolder stockHolder;
public Transactions()
{
}
public Transactions(TransactionsPK transactionsPK)
{
this.transactionsPK = transactionsPK;
}
public Transactions(TransactionsPK transactionsPK, int qty)
{
this.transactionsPK = transactionsPK;
this.qty = qty;
}
public Transactions(int stockHolderId, String stockId)
{
this.transactionsPK = new TransactionsPK(stockHolderId, stockId);
}
public TransactionsPK getTransactionsPK()
{
return transactionsPK;
}
public void setTransactionsPK(TransactionsPK transactionsPK)
{
this.transactionsPK = transactionsPK;
}
public int getQty()
{
return qty;
}
public void setQty(int qty)
{
this.qty = qty;
}
public Stock getStock()
{
return stock;
}
public void setStock(Stock stock)
{
this.stock = stock;
}
public StockHolder getStockHolder()
{
return stockHolder;
}
public void setStockHolder(StockHolder stockHolder)
{
this.stockHolder = stockHolder;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (transactionsPK != null ? transactionsPK.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Transactions))
{
return false;
}
Transactions other = (Transactions) object;
if ((this.transactionsPK == null && other.transactionsPK != null) || (this.transactionsPK != null && !this.transactionsPK.equals(other.transactionsPK)))
{
return false;
}
return true;
}
@Override
public String toString()
{
return "asdv.mp1_ajax.entities.Transactions[ transactionsPK=" + transactionsPK + " ]";
}
}

@ -0,0 +1,87 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package asdv.mp1_ajax.pojos;
import java.io.Serializable;
import jakarta.persistence.Embeddable;
/**
*
* @author asdv5
*/
@Embeddable
public class TransactionsPK implements Serializable
{
private int stockHolderId;
private String stockId;
public TransactionsPK()
{
}
public TransactionsPK(int stockHolderId, String stockId)
{
this.stockHolderId = stockHolderId;
this.stockId = stockId;
}
public int getStockHolderId()
{
return stockHolderId;
}
public void setStockHolderId(int stockHolderId)
{
this.stockHolderId = stockHolderId;
}
public String getStockId()
{
return stockId;
}
public void setStockId(String stockId)
{
this.stockId = stockId;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (int) stockHolderId;
hash += (stockId != null ? stockId.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object)
{
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof TransactionsPK))
{
return false;
}
TransactionsPK other = (TransactionsPK) object;
if (this.stockHolderId != other.stockHolderId)
{
return false;
}
if ((this.stockId == null && other.stockId != null) || (this.stockId != null && !this.stockId.equals(other.stockId)))
{
return false;
}
return true;
}
@Override
public String toString()
{
return "asdv.mp1_ajax.entities.TransactionsPK[ stockHolderId=" + stockHolderId + ", stockId=" + stockId + " ]";
}
}

@ -0,0 +1,20 @@
package asdv.mp1_ajax.resources;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;
/**
*
* @author
*/
@Path("jakartaee10")
public class JakartaEE10Resource {
@GET
public Response ping(){
return Response
.ok("ping Jakarta EE")
.build();
}
}

@ -0,0 +1,36 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSF/JSFManagedBean.java to edit this template
*/
package beans;
import edu.slcc.ajax.bl.StockDB;
import jakarta.enterprise.context.SessionScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import java.io.Serializable;
/**
*
* @author asdv5
*/
@Named(value="stockBean")
@SessionScoped
public class StockBean implements Serializable
{
@Inject
StockDB stocks;
/** Creates a new instance of StockBean */
public StockBean() {
}
public StockDB getStocks()
{
return stocks;
}
}

@ -0,0 +1,28 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
*/
package edu.slcc.ajax.bl;
import java.sql.SQLException;
import java.util.List;
public interface Dao<T>
{
void create(T t);
void edit(T t);
void remove(T t);
T find(Object id) ;
List<T> findAll()
throws SQLException;;
List<T> findRange(int[] range);
int count();
}

@ -0,0 +1,73 @@
package edu.slcc.ajax.bl;
import java.sql.Connection;
import java.util.List;
import java.util.Map;
/**
*
* @author ASDV2
*/
public interface Database
{
/**
* Returns a Connection to a database or null if no connection is done.
*
* @param databaseName name
* @param userName database user name
* @param password database password
* @param driver driver that connects us to database
* @return Connection the connection to database or null if no connection
*/
public Connection getConnection(String databaseName, String userName, String password, String driver);
/**
* Selects the projected columns of a table where the AND condition of the
* WHERE clause is true.
*
* @param tableName table name
* @param projectionFields fields if SELECT clause ( projected columns)
* @param whereFieldsNValues fields in WHERE clause, key is the field name(
* LHS ) and value of the field ( RHS ). For example snumber = 's1', status
* > "10".
* @param operators the operators that apply to whereFieldsNValues. They are
* positioned between the LHS and the RHS of the whereFieldsNValues
* parameter. The operators are always the same size as the
* whereFieldsNValues. That is,the first operator applies to the first entry
* of the map, the second operator to the 2nd entry and so on.
* @return the projected columns of a table, after the WHERE clause applies
* by ANDing all entries of the map ( whereFieldsNValues). If an SQL
* exception is thrown return NULL if an error ( exception occurs).
*
*/
public List<String> selectFieldsFromTableWhereFields(String tableName,
List<String> projectionFields,
Map<String, String> whereFieldsNValues,
List<String> operators
);
/**
* Returns the list of all rows of the table "tableName"
*
* @param tableName the name of the table to return
* @return a list with all rows in the the table.
*/
public List<String> selectAllFromTable(String tableName);
/**
* Returns true if the table exists in the database, false otherwise
*
* @param tableName the name of the table
* @return true if the table exists in the database, false otherwise
*/
boolean isTable(String tableName);
/**
* Closes a connection
*
* @param c the connection to close
*/
public void closeConnection(Connection c);
}

@ -0,0 +1,129 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package edu.slcc.ajax.bl;
import asdv.mp1_ajax.pojos.Stock;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;
/**
*
* @author asdv5
*/
public class StockDB
implements Dao<Stock>, Serializable
{
@Override
public List<Stock> findAll()
throws SQLException
{
// test exception code
//if ( true)
// throw new SQLException();
List<Stock> tableStocks = new ArrayList<Stock>();
String databaseName = "nyse";
String userName = "java";
String password = "dA^vTFd8&JDvt8HjiNVahgSj";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = new UtilitiesDatabase().connection(
databaseName, userName, password, URL2);
PreparedStatement ps = null;
try
{
if (con == null)
{
throw new RuntimeException("cannot connect to database");
}
String table = "";
ResultSet rs = null;
String sqlStr = "SELECT * FROM stock";
//prepare statement
ps = con.prepareStatement(sqlStr);
//execute
rs = ps.executeQuery();
while (rs.next())
{
String stockId = rs.getString(1);
String companyName = rs.getString(2);
double priceCurrent = rs.getDouble(3);
double priceClosing = rs.getDouble(4);
long numberOfSharesAvailable = rs.getLong(5);
long numberOfSharesSold = rs.getLong(6);
Stock stock = new Stock(stockId, companyName, priceCurrent, priceClosing, numberOfSharesAvailable, numberOfSharesSold);
tableStocks.add(stock);
}
}
catch (Exception ex)
{
ex.printStackTrace();
throw ex;
}
finally
{
try
{
new UtilitiesDatabase().closeDatabaseConnection(con);
// close the resources
if (ps != null)
{
ps.close();
}
}
catch (SQLException sqle)
{
System.out.println(sqle);
sqle.printStackTrace();
throw sqle;
}
}
return tableStocks;
}
@Override
public void create(Stock t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public void edit(Stock t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public void remove(Stock t)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public Stock find(Object id)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public List<Stock> findRange(int[] range)
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
@Override
public int count()
{
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
}

@ -0,0 +1,103 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package edu.slcc.ajax.bl;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
*
* @author asdv5
*/
public class UtilitiesDatabase
{
public Connection connection(
String databaseName,
String userName,
String password,
String URL2
) //throws InstantiationException, IllegalAccessException
{
/*
String databaseName = "suppliers_parts_23";
String userName = "root";
String password = "root";
String URL2 = "com.mysql.jdbc.Driver";
Connection con = null;
*/
Connection con;
try
{// Load Sun's jdbc driver
Class.forName(URL2).newInstance();
System.out.println("JDBC Driver loaded!");
}
catch (Exception e) // driver not found
{
System.err.println("Unable to load database driver");
System.err.println("Details : " + e);
return null;
}
String ip = "localhost"; //internet connection
String url = "jdbc:mysql://" + ip + ":3306/" + databaseName + "?allowPublicKeyRetrieval=true&useSSL=false";
try
{
con = DriverManager.getConnection(url, userName, password);
con.setReadOnly(false);
}
catch (Exception e)
{
System.err.println(e.toString());
return null;
}
System.out.println("connection successfull");
return con;
}
public void closeDatabaseConnection( Connection con)
{
try
{
if (con != null)
{
con.close();
}
}
catch (SQLException e)
{
System.out.println(e);
e.printStackTrace();
}
}
public static java.sql.Date stringDateToSqlDate(String sDate)
{
java.util.Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try
{
date = sdf.parse(sDate);
}
catch (ParseException e)
{
e.printStackTrace();
}
return new java.sql.Date( date.getTime() );
}
public static java.util.Date stringDateToJavaUtilitiesDate(String sDate)
{
java.sql.Date sqldate = stringDateToSqlDate(sDate);
return new java.util.Date(sqldate.getTime() );
}
}

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="3.0" xmlns="https://jakarta.ee/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd">
<persistence-unit name="asdv_MP1_Ajax_war_1PU" transaction-type="JTA">
<jta-data-source>java:app/nyse</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties/>
</persistence-unit>
</persistence>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
bean-discovery-mode="all">
</beans>

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="mysql_nyse_rootPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="8889"/>
<property name="databaseName" value="nyse"/>
<property name="User" value="root"/>
<property name="Password" value="root"/>
<property name="URL" value="jdbc:mysql://localhost:8889/nyse?zeroDateTimeBehavior=CONVERT_TO_NULL"/>
<property name="driverClass" value="com.mysql.cj.jdbc.Driver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="java:app/nyse" object-type="user" pool-name="mysql_nyse_rootPool"/>
<jdbc-resource enabled="true" jndi-name="java:app/nyse1" object-type="user" pool-name="mysql_nyse_rootPool"/>
</resources>

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</glassfish-web-app>

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="6.0" xmlns="https://jakarta.ee/xml/ns/jakartaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<context-param>
<param-name>jakarta.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

@ -0,0 +1,49 @@
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:f5="http://xmlns.jcp.org/jsf/passthrough">
<h:head>
<title>MP1 Ajax</title>
<h:outputStylesheet library="css" name="styles.css"/>
</h:head>
<h:body>
<h:form>
<p:dataTable id= "id_dataTable1" value ="#{stockBean.getStocks().findAll() }"
style="width: 100%; "
var="stock"
scrollable="true"
paginator="true"
rowHover ="true"
paginatorPosition="bottom"
>
<p:column headerText="Stock ID" >
<p:outputLabel title= "Stock ID" value="#{stock.stockId}" />
</p:column >
<p:column headerText="Stock Name" >
<p:outputLabel title= "Stock Name" value="#{stock.companyName}" />
</p:column >
<p:column headerText="Current Price" >
<p:outputLabel title= "Current Price" value="#{stock.priceCurrent}" />
</p:column >
<p:column headerText="Closing Price" >
<p:outputLabel title= "Closing Price" value="#{stock.priceClosing}" />
</p:column >
<p:column headerText="Shares Avialable" >
<p:outputLabel title= "Shares Avialable" value="#{stock.numberOfSharesAvailable}" />
</p:column >
<p:column headerText="Shares Sold" >
<p:outputLabel title= "Shares Sold" value="#{stock.numberOfSharesSold}" />
</p:column >
</p:dataTable>
</h:form>
</h:body>
</html>

@ -0,0 +1,45 @@
/*
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/CascadeStyleSheet.css to edit this template
*/
/*
Created on : Jan 13, 2024, 9:50:00 AM
Author : asdv5
*/
.grandParent{
margin:0 auto;
float:left;
min-width:100px;
max-width:120px;
height:150px;
position:relative;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
background:#cccccc;
font-size:11px;
cursor:pointer;
}
.theColumn{
width:100%;
padding: 20px;
background-color: blue;
}
.elementsOfTheColumn{
width:60%;
margin-left: 10px;
display:inline-table;
position:relative;
}
.elementsOfTheColumnButton{
width:30%;
margin-left: 10px;
display:inline-table;
position:relative;
}

@ -0,0 +1,44 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package edu.slcc.asdv.caleb.maxtask;
import java.math.BigInteger;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;
/**
*
* @author caleb
*/
public class Factorial extends RecursiveTask<Integer>
{
final int n;
Factorial(int n)
{
this.n = n;
}
@Override
protected Integer compute()
{
if (n == 1 || n <= 1)
{
return n;
}
Factorial fact = new Factorial(n - 1);
fact.fork();
return n * fact.join();
}
public static void main(String[] args)
{
RecursiveTask<Integer> task = new Factorial(4);
ForkJoinPool pool = new ForkJoinPool();
int fact = pool.invoke(task);
System.out.println(fact);
}
}

@ -0,0 +1,58 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package edu.slcc.asdv.caleb.maxtask;
/**
*
* @author caleb
*/
import java.math.BigInteger;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;
public class FactorialBig extends RecursiveTask<BigInteger>
{
final int THRESHOLD = 50;
public static void main(String[] args)
{
RecursiveTask<BigInteger> task = new FactorialBig( new BigInteger( "1060"));
ForkJoinPool pool = new ForkJoinPool();
BigInteger fact = pool.invoke(task);
System.out.println(fact);
}
final BigInteger n;
FactorialBig(BigInteger n)
{
this.n = n;
}
@Override
protected BigInteger compute()
{
if (this.n.compareTo(new BigInteger(String.valueOf(THRESHOLD))) < 0)
{
if (n == BigInteger.ONE || n == BigInteger.ZERO)
return BigInteger.ONE;
long fact = 1;
//compare factorial with loop
for (int i = 2; i < THRESHOLD; ++i)
{
fact *= i;
}
return new BigInteger(String.valueOf(fact));
}
else {
//compute factorial in parallel
FactorialBig factBig = new FactorialBig(n.subtract(BigInteger.ONE));
factBig.fork();
return n.multiply(factBig.join());
}
}
}

@ -0,0 +1,50 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package edu.slcc.asdv.caleb.maxtask;
/**
*
* @author caleb
*/
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.RecursiveTask;
public class Fibonacci extends RecursiveTask<Integer>
{
final int n;
Fibonacci(int n)
{
this.n = n;
}
@Override
protected Integer compute()
{
if (n <= 1)
{
return n;
}
Fibonacci f1 = new Fibonacci(n - 1);
f1.fork();
Fibonacci f2 = new Fibonacci(n - 2);
return f2.compute() + f1.join();
}
public static void main(String[] args)
{
RecursiveTask<Integer> task = new Fibonacci(8);
ForkJoinPool pool = new ForkJoinPool();
int fib = pool.invoke(task);
System.out.println(fib);
}
}
class Test
{
}

@ -14,7 +14,7 @@ public class ParallelMax
public static void main(String[] args)
{
// Create a list
final int N = 20;
final int N = 999999999;
int[] list = new int[N];
for (int i = 0; i < list.length; i++)
list[i] = i;
@ -75,21 +75,21 @@ public class ParallelMax
for (int i = low; i < high; i++)
if (list[i] > max)
max = list[i];
return new Integer(max);
return max;
}
else
{
int mid = (low + high) / 2;
RecursiveTask<Integer> left = new MaxTask(list, low, mid);
System.out.println("left: " + low +", " + high);
//System.out.println("left: " + low +", " + high);
RecursiveTask<Integer> right = new MaxTask(list, mid+1, high);
System.out.println("right: " + (mid + 1) +", " + high);
System.out.println("fork right");
//System.out.println("right: " + (mid + 1) +", " + high);
//System.out.println("fork right");
right.fork();
System.out.println("fork left");
//System.out.println("fork left");
left.fork();
return new Integer(Math.max( left.join().intValue(),
right.join().intValue())
return Math.max( left.join().intValue(),
right.join().intValue()
);
}
}

@ -0,0 +1,106 @@
-- phpMyAdmin SQL Dump
-- version 5.2.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost:8889
-- Generation Time: Feb 20, 2024 at 06:27 PM
-- Server version: 5.7.39
-- PHP Version: 7.4.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `nyse`
--
-- --------------------------------------------------------
--
-- Table structure for table `stock`
--
CREATE TABLE `stock` (
`stock_id` varchar(4) NOT NULL,
`company_name` varchar(100) NOT NULL,
`price_current` double NOT NULL,
`price_closing` double NOT NULL,
`number_of_shares_available` bigint(20) NOT NULL,
`number_of_shares_sold` bigint(20) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `stock`
--
INSERT INTO `stock` (`stock_id`, `company_name`, `price_current`, `price_closing`, `number_of_shares_available`, `number_of_shares_sold`) VALUES
('PLCE', 'Children\'s Place, Inc.', 14.515, 13.515, 10000000, 5000000);
-- --------------------------------------------------------
--
-- Table structure for table `stock_holder`
--
CREATE TABLE `stock_holder` (
`stock_holder_id` int(11) NOT NULL,
`name` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
-- Table structure for table `transactions`
--
CREATE TABLE `transactions` (
`stock_holder_id` int(11) NOT NULL,
`stock_id` varchar(4) NOT NULL,
`qty` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `stock`
--
ALTER TABLE `stock`
ADD PRIMARY KEY (`stock_id`);
--
-- Indexes for table `stock_holder`
--
ALTER TABLE `stock_holder`
ADD PRIMARY KEY (`stock_holder_id`);
--
-- Indexes for table `transactions`
--
ALTER TABLE `transactions`
ADD PRIMARY KEY (`stock_holder_id`,`stock_id`),
ADD KEY `stock_id` (`stock_id`);
--
-- Constraints for dumped tables
--
--
-- Constraints for table `transactions`
--
ALTER TABLE `transactions`
ADD CONSTRAINT `transactions_ibfk_1` FOREIGN KEY (`stock_id`) REFERENCES `stock` (`stock_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `transactions_ibfk_2` FOREIGN KEY (`stock_holder_id`) REFERENCES `stock_holder` (`stock_holder_id`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;