import sources from develop/0.1.0
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.peetz.tradingcards.dal;
|
||||
|
||||
import com.peetz.tradingcards.entity.BaseSetEntity;
|
||||
import com.peetz.tradingcards.entity.ManufacturerEntity;
|
||||
import java.util.List;
|
||||
import javax.ejb.Local;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
@Local
|
||||
public interface ManufacturerDao {
|
||||
public ManufacturerEntity getById(Long id);
|
||||
|
||||
public List<ManufacturerEntity> findByIds(List<Long> ids);
|
||||
|
||||
public List<ManufacturerEntity> findByName(String name);
|
||||
|
||||
public ManufacturerEntity assignBaseSet(ManufacturerEntity comic, BaseSetEntity baseSet);
|
||||
|
||||
public ManufacturerEntity store(ManufacturerEntity entity);
|
||||
|
||||
public void delete(ManufacturerEntity entity);
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.peetz.tradingcards.dal;
|
||||
|
||||
import com.peetz.tradingcards.entity.BaseSetEntity;
|
||||
import com.peetz.tradingcards.entity.ManufacturerEntity;
|
||||
import java.util.List;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
@Stateless(name = "ManufacturerDao")
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public class ManufacturerImpl implements ManufacturerDao {
|
||||
|
||||
@PersistenceContext(unitName = "kontor")
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
public ManufacturerEntity getById(Long id) {
|
||||
Query q = em.createNamedQuery("Manufacturer.findById");
|
||||
q.setParameter("id", id);
|
||||
ManufacturerEntity entity = (ManufacturerEntity)q.getSingleResult();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ManufacturerEntity> findByIds(List<Long> ids) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<ManufacturerEntity> findByName(String name) {
|
||||
Query q = em.createNamedQuery("Manufacturer.findByName");
|
||||
q.setParameter("name", name);
|
||||
List<ManufacturerEntity> resultList = q.getResultList();
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManufacturerEntity assignBaseSet(ManufacturerEntity comic, BaseSetEntity baseSet) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManufacturerEntity store(ManufacturerEntity entity) {
|
||||
em.persist(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ManufacturerEntity entity) {
|
||||
em.remove(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.peetz.tradingcards.dal;
|
||||
|
||||
import com.peetz.tradingcards.entity.SportEntity;
|
||||
import java.util.List;
|
||||
import javax.ejb.Local;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
@Local
|
||||
public interface SportDao {
|
||||
public SportEntity getById(Long id);
|
||||
|
||||
public List<SportEntity> findByIds(List<Long> ids);
|
||||
|
||||
public List<SportEntity> findByName(String name);
|
||||
|
||||
public SportEntity store(SportEntity entity);
|
||||
|
||||
public void delete(SportEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.peetz.tradingcards.dal;
|
||||
|
||||
import com.peetz.tradingcards.entity.SportEntity;
|
||||
import java.util.List;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
@Stateless(name = "SportDao")
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public class SportImpl implements SportDao {
|
||||
|
||||
@PersistenceContext(unitName = "kontor")
|
||||
private EntityManager em;
|
||||
|
||||
@Override
|
||||
public SportEntity getById(Long id) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SportEntity> findByIds(List<Long> ids) {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<SportEntity> findByName(String name) {
|
||||
Query query = em.createNamedQuery("Sport.findByName");
|
||||
query.setParameter("name", name);
|
||||
List<SportEntity> resultList = query.getResultList();
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SportEntity store(SportEntity entity) {
|
||||
em.persist(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SportEntity entity) {
|
||||
em.remove(entity);
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="BASESET")
|
||||
public class BaseSetEntity {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ManufacturerEntity manufacturer;
|
||||
private Collection<ParallelSetEntity> parallelSets = new ArrayList<ParallelSetEntity>();
|
||||
private Collection<InsertEntity> inserts = new ArrayList<InsertEntity>();
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public ManufacturerEntity getManufacturer() {
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public void setManufacturer(ManufacturerEntity manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="baseSet", cascade=CascadeType.REMOVE)
|
||||
public Collection<ParallelSetEntity> getParallelSets() {
|
||||
return parallelSets;
|
||||
}
|
||||
|
||||
public void setParallelSets(Collection<ParallelSetEntity> parallelSets) {
|
||||
this.parallelSets = parallelSets;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="baseSet", cascade=CascadeType.REMOVE)
|
||||
public Collection<InsertEntity> getInserts() {
|
||||
return inserts;
|
||||
}
|
||||
|
||||
public void setInserts(Collection<InsertEntity> inserts) {
|
||||
this.inserts = inserts;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="InsertSet.findAll", query="SELECT i from InsertEntity as i"),
|
||||
@NamedQuery(name="InsertSet.findById", query="SELECT i from InsertEntity as i WHERE i.id = :id"),
|
||||
@NamedQuery(name="InsertSet.findByName", query="SELECT i from InsertEntity as i WHERE i.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="INSERTSET")
|
||||
public class InsertEntity {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ManufacturerEntity manufacturer;
|
||||
private BaseSetEntity baseSet;
|
||||
private Collection<SportCardEntity> sportCard = new ArrayList<SportCardEntity>();
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public ManufacturerEntity getManufacturer() {
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public void setManufacturer(ManufacturerEntity manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public BaseSetEntity getBaseSet() {
|
||||
return baseSet;
|
||||
}
|
||||
|
||||
public void setBaseSet(BaseSetEntity baseSet) {
|
||||
this.baseSet = baseSet;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="insert", cascade=CascadeType.REMOVE)
|
||||
public Collection<SportCardEntity> getSportCard() {
|
||||
return sportCard;
|
||||
}
|
||||
|
||||
public void setSportCard(Collection<SportCardEntity> sportCard) {
|
||||
this.sportCard = sportCard;
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Manufacturer.findAll", query="SELECT m from ManufacturerEntity as m"),
|
||||
@NamedQuery(name="Manufacturer.findByName", query="SELECT m from ManufacturerEntity as m WHERE m.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="MANUFACTURER")
|
||||
public class ManufacturerEntity {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private Collection<BaseSetEntity> baseSets = new ArrayList<BaseSetEntity>();
|
||||
private Collection<ParallelSetEntity> parallelSets = new ArrayList<ParallelSetEntity>();
|
||||
private Collection<InsertEntity> inserts = new ArrayList<InsertEntity>();
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
|
||||
public Collection<BaseSetEntity> getBaseSets() {
|
||||
return baseSets;
|
||||
}
|
||||
|
||||
public void setBaseSets(Collection<BaseSetEntity> baseSets) {
|
||||
this.baseSets = baseSets;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
|
||||
public Collection<ParallelSetEntity> getParallelSets() {
|
||||
return parallelSets;
|
||||
}
|
||||
|
||||
public void setParallelSets(Collection<ParallelSetEntity> parallelSets) {
|
||||
this.parallelSets = parallelSets;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="manufacturer", cascade=CascadeType.REMOVE)
|
||||
public Collection<InsertEntity> getInserts() {
|
||||
return inserts;
|
||||
}
|
||||
|
||||
public void setInserts(Collection<InsertEntity> inserts) {
|
||||
this.inserts = inserts;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="PARALLELSET")
|
||||
public class ParallelSetEntity {
|
||||
private Long id;
|
||||
private String name;
|
||||
private ManufacturerEntity manufacturer;
|
||||
|
||||
private BaseSetEntity baseSet;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public ManufacturerEntity getManufacturer() {
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public void setManufacturer(ManufacturerEntity manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public BaseSetEntity getBaseSet() {
|
||||
return baseSet;
|
||||
}
|
||||
|
||||
public void setBaseSet(BaseSetEntity baseSet) {
|
||||
this.baseSet = baseSet;
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="PLAYER")
|
||||
public class PlayerEntity {
|
||||
private Long id;
|
||||
private TeamEntity team;
|
||||
private Collection<SportCardEntity> cards = new ArrayList<SportCardEntity>();
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@ManyToOne
|
||||
public TeamEntity getTeam() {
|
||||
return team;
|
||||
}
|
||||
|
||||
public void setTeam(TeamEntity team) {
|
||||
this.team = team;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="player", cascade=CascadeType.REMOVE)
|
||||
public Collection<SportCardEntity> getCards() {
|
||||
return cards;
|
||||
}
|
||||
|
||||
public void setCards(Collection<SportCardEntity> cards) {
|
||||
this.cards = cards;
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="POSITION")
|
||||
public class PositionEntity {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String shortName;
|
||||
private SportEntity sport;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getShortName() {
|
||||
return shortName;
|
||||
}
|
||||
|
||||
public void setShortName(String shortName) {
|
||||
this.shortName = shortName;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public SportEntity getSport() {
|
||||
return sport;
|
||||
}
|
||||
|
||||
public void setSport(SportEntity sport) {
|
||||
this.sport = sport;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="SportCard.findAll", query="SELECT s from SportCardEntity as s")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "SPORTCARD")
|
||||
public class SportCardEntity {
|
||||
private Long id;
|
||||
private PlayerEntity player;
|
||||
private BaseSetEntity baseSet;
|
||||
private ParallelSetEntity parallelSet;
|
||||
private InsertEntity insert;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@ManyToOne
|
||||
public PlayerEntity getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setPlayer(PlayerEntity player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public BaseSetEntity getBaseSet() {
|
||||
return baseSet;
|
||||
}
|
||||
|
||||
public void setBaseSet(BaseSetEntity baseSet) {
|
||||
this.baseSet = baseSet;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public ParallelSetEntity getParallelSet() {
|
||||
return parallelSet;
|
||||
}
|
||||
|
||||
public void setParallelSet(ParallelSetEntity parallelSet) {
|
||||
this.parallelSet = parallelSet;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public InsertEntity getInsert() {
|
||||
return insert;
|
||||
}
|
||||
|
||||
public void setInsert(InsertEntity insert) {
|
||||
this.insert = insert;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Sport.findAll", query="SELECT s from SportEntity as s"),
|
||||
@NamedQuery(name="Sport.findByName", query="SELECT s from SportEntity as s WHERE s.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="SPORT")
|
||||
public class SportEntity {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private Collection<TeamEntity> teams = new ArrayList<TeamEntity>();
|
||||
private Collection<PositionEntity> positions = new ArrayList<PositionEntity>();
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="sport", cascade=CascadeType.REMOVE)
|
||||
public Collection<TeamEntity> getTeams() {
|
||||
return teams;
|
||||
}
|
||||
|
||||
public void setTeams(Collection<TeamEntity> teams) {
|
||||
this.teams = teams;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="sport", cascade=CascadeType.REMOVE)
|
||||
public Collection<PositionEntity> getPositions() {
|
||||
return positions;
|
||||
}
|
||||
|
||||
public void setPositions(Collection<PositionEntity> positions) {
|
||||
this.positions = positions;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.peetz.tradingcards.entity;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Team.findAll", query="SELECT t from TeamEntity as t"),
|
||||
@NamedQuery(name="Team.findByName", query="SELECT t from TeamEntity as t WHERE t.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="TEAM")
|
||||
public class TeamEntity {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private SportEntity sport;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getName() { return name; }
|
||||
|
||||
public void setName(String name) { this.name = name; }
|
||||
|
||||
@ManyToOne
|
||||
public SportEntity getSport() { return sport; }
|
||||
|
||||
public void setSport(SportEntity sport) { this.sport = sport; }
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.peetz.tradingcards.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.peetz.tradingcards.entity.PositionEntity;
|
||||
import com.peetz.tradingcards.entity.SportEntity;
|
||||
import com.peetz.tradingcards.entity.TeamEntity;
|
||||
|
||||
@Local
|
||||
public interface SportService {
|
||||
|
||||
Collection<SportEntity> getAllSports();
|
||||
|
||||
Collection<TeamEntity> getAllTeams();
|
||||
|
||||
void addSport(String name);
|
||||
|
||||
Collection<TeamEntity> getTeams(SportEntity sport);
|
||||
|
||||
Collection<PositionEntity> getPositions(SportEntity sport);
|
||||
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.peetz.tradingcards.service;
|
||||
|
||||
import com.peetz.tradingcards.dal.SportDao;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
|
||||
import com.peetz.tradingcards.entity.PositionEntity;
|
||||
import com.peetz.tradingcards.entity.SportEntity;
|
||||
import com.peetz.tradingcards.entity.TeamEntity;
|
||||
import java.util.ArrayList;
|
||||
import javax.ejb.EJB;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
@Stateless(name="SportService")
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public class SportServiceImpl implements SportService {
|
||||
|
||||
@PersistenceContext(unitName = "kontor")
|
||||
private EntityManager em;
|
||||
|
||||
@EJB
|
||||
SportDao sportDao;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<SportEntity> getAllSports() {
|
||||
Query query = em.createNamedQuery("Sport.findAll");
|
||||
ArrayList<SportEntity> sportList = new ArrayList<SportEntity>(query.getResultList());
|
||||
return sportList;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<TeamEntity> getAllTeams() {
|
||||
Query query = em.createNamedQuery("Team.findAll");
|
||||
ArrayList<TeamEntity> teamList = new ArrayList<TeamEntity>(query.getResultList());
|
||||
return teamList;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addSport(String name) {
|
||||
SportEntity entity = new SportEntity();
|
||||
entity.setName(name);
|
||||
sportDao.store(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TeamEntity> getTeams(SportEntity sport) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PositionEntity> getPositions(SportEntity sport) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.peetz.tradingcards.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.peetz.tradingcards.entity.BaseSetEntity;
|
||||
import com.peetz.tradingcards.entity.InsertEntity;
|
||||
import com.peetz.tradingcards.entity.ManufacturerEntity;
|
||||
import com.peetz.tradingcards.entity.ParallelSetEntity;
|
||||
import com.peetz.tradingcards.entity.SportCardEntity;
|
||||
|
||||
@Local
|
||||
public interface TradingcardService {
|
||||
|
||||
Collection<ManufacturerEntity> getAllManufacturers();
|
||||
|
||||
void addManufacturer(String name);
|
||||
|
||||
Collection<SportCardEntity> getAllSportCards();
|
||||
|
||||
Collection<BaseSetEntity> getBaseSetsByManufacturer(ManufacturerEntity manufacturer);
|
||||
|
||||
Collection<ParallelSetEntity> getParallelSetsByManufacturer(ManufacturerEntity manufacturer);
|
||||
|
||||
Collection<InsertEntity> getInsertsByManufacturer(ManufacturerEntity manufacturer);
|
||||
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.peetz.tradingcards.service;
|
||||
|
||||
import com.peetz.tradingcards.dal.ManufacturerDao;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
|
||||
import com.peetz.tradingcards.entity.BaseSetEntity;
|
||||
import com.peetz.tradingcards.entity.InsertEntity;
|
||||
import com.peetz.tradingcards.entity.ManufacturerEntity;
|
||||
import com.peetz.tradingcards.entity.ParallelSetEntity;
|
||||
import com.peetz.tradingcards.entity.SportCardEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.ejb.EJB;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
@Stateless(name="TradingcardService")
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public class TradingcardServiceImpl implements TradingcardService {
|
||||
|
||||
@PersistenceContext(unitName = "kontor")
|
||||
private EntityManager em;
|
||||
|
||||
@EJB
|
||||
ManufacturerDao manufacturerDao;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<ManufacturerEntity> getAllManufacturers() {
|
||||
Query query = em.createNamedQuery("Manufacturer.findAll");
|
||||
ArrayList<ManufacturerEntity> manufacturerList = new ArrayList<ManufacturerEntity>(query.getResultList());
|
||||
return manufacturerList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addManufacturer(String name) {
|
||||
List<ManufacturerEntity> resultList = manufacturerDao.findByName(name);
|
||||
if (resultList.isEmpty()) {
|
||||
ManufacturerEntity manufacturer = new ManufacturerEntity();
|
||||
manufacturer.setName(name);
|
||||
manufacturerDao.store(manufacturer);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<SportCardEntity> getAllSportCards() {
|
||||
Query query = em.createNamedQuery("SportCard.findAll");
|
||||
ArrayList<SportCardEntity> sportCardList = new ArrayList<SportCardEntity>(query.getResultList());
|
||||
return sportCardList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BaseSetEntity> getBaseSetsByManufacturer(ManufacturerEntity manufacturer) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ParallelSetEntity> getParallelSetsByManufacturer(ManufacturerEntity manufacturer) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<InsertEntity> getInsertsByManufacturer(ManufacturerEntity manufacturer) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @author TPEETZ
|
||||
*
|
||||
*/
|
||||
package com.peetz.tradingcards.service;
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package com.peetz.tradingcards.dal;
|
||||
|
||||
import com.peetz.tradingcards.entity.BaseSetEntity;
|
||||
import com.peetz.tradingcards.entity.ManufacturerEntity;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.ejb.embeddable.EJBContainer;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
public class ManufacturerImplTest {
|
||||
|
||||
public ManufacturerImplTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getById method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testGetById() throws Exception {
|
||||
System.out.println("getById");
|
||||
Long id = null;
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/main/ManufacturerDao");
|
||||
ManufacturerEntity expResult = null;
|
||||
ManufacturerEntity result = instance.getById(id);
|
||||
assertEquals(expResult, result);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of findByIds method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testFindByIds() throws Exception {
|
||||
System.out.println("findByIds");
|
||||
List<Long> ids = null;
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/classes/ManufacturerImpl");
|
||||
Collection<ManufacturerEntity> expResult = null;
|
||||
Collection<ManufacturerEntity> result = instance.findByIds(ids);
|
||||
assertEquals(expResult, result);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of findByName method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testFindByName() throws Exception {
|
||||
System.out.println("findByName");
|
||||
String name = "";
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/classes/ManufacturerImpl");
|
||||
Collection<ManufacturerEntity> expResult = null;
|
||||
Collection<ManufacturerEntity> result = instance.findByName(name);
|
||||
assertEquals(expResult, result);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of assignBaseSet method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testAssignBaseSet() throws Exception {
|
||||
System.out.println("assignBaseSet");
|
||||
ManufacturerEntity comic = null;
|
||||
BaseSetEntity baseSet = null;
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/classes/ManufacturerImpl");
|
||||
ManufacturerEntity expResult = null;
|
||||
ManufacturerEntity result = instance.assignBaseSet(comic, baseSet);
|
||||
assertEquals(expResult, result);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of store method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testStore() throws Exception {
|
||||
System.out.println("store");
|
||||
ManufacturerEntity entity = null;
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/classes/ManufacturerImpl");
|
||||
ManufacturerEntity expResult = null;
|
||||
ManufacturerEntity result = instance.store(entity);
|
||||
assertEquals(expResult, result);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of delete method, of class ManufacturerImpl.
|
||||
*/
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
System.out.println("delete");
|
||||
ManufacturerEntity entity = null;
|
||||
EJBContainer container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
|
||||
ManufacturerDao instance = (ManufacturerDao)container.getContext().lookup("java:global/classes/ManufacturerImpl");
|
||||
instance.delete(entity);
|
||||
container.close();
|
||||
// TODO review the generated test code and remove the default call to fail.
|
||||
fail("The test case is a prototype.");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user