import repositories kontor-java and kontor-ee
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author TPEETZ
|
||||
*
|
||||
*/
|
||||
package com.peetz.medien.dal;
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.peetz.medien.entity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
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.Table;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="AudioCD.findAll", query="SELECT c from AudioCDEntity as c"),
|
||||
@NamedQuery(name="AudioCD.findByAlbum", query="SELECT c from AudioCDEntity as c WHERE c.album = :album")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="AUDIOCD")
|
||||
public class AudioCDEntity
|
||||
{
|
||||
private Long id;
|
||||
private String album;
|
||||
private String artist;
|
||||
private String category;
|
||||
private String releaseYear;
|
||||
private Boolean wantList;
|
||||
private Collection<String> songs;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getAlbum() {
|
||||
return album;
|
||||
}
|
||||
|
||||
public void setAlbum(String album) {
|
||||
this.album = album;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getArtist() {
|
||||
return artist;
|
||||
}
|
||||
|
||||
public void setArtist(String artist) {
|
||||
this.artist = artist;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getReleaseYear() {
|
||||
return releaseYear;
|
||||
}
|
||||
|
||||
public void setReleaseYear(String releaseYear) {
|
||||
this.releaseYear = releaseYear;
|
||||
}
|
||||
|
||||
@Column
|
||||
public Boolean getWantList() {
|
||||
return wantList;
|
||||
}
|
||||
|
||||
public void setWantList(Boolean wantList) {
|
||||
this.wantList = wantList;
|
||||
}
|
||||
|
||||
@Column
|
||||
public Collection<String> getSongs() {
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void setSongs(Collection<String> songs) {
|
||||
this.songs = songs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.peetz.medien.entity;
|
||||
|
||||
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.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name="BOXSET")
|
||||
public class BoxSetEntity
|
||||
{
|
||||
private Long id;
|
||||
private String title;
|
||||
private Collection<FilmEntity> films;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getTitle() { return title; }
|
||||
|
||||
public void setTitle(String title) { this.title = title; }
|
||||
|
||||
@OneToMany(mappedBy="boxSet", cascade=CascadeType.REMOVE)
|
||||
public Collection<FilmEntity> getFilms() {
|
||||
return films;
|
||||
}
|
||||
|
||||
public void setFilms(Collection<FilmEntity> films) {
|
||||
this.films = films;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.peetz.medien.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="Film.findAll", query="SELECT f from FilmEntity as f"),
|
||||
@NamedQuery(name="Film.findByTitle", query="SELECT f from FilmEntity as f WHERE f.title = :title")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="FILM")
|
||||
public class FilmEntity
|
||||
{
|
||||
private Long id;
|
||||
private String title;
|
||||
private BoxSetEntity boxSet;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public BoxSetEntity getBoxSet() {
|
||||
return boxSet;
|
||||
}
|
||||
|
||||
public void setBoxSet(BoxSetEntity boxSet) {
|
||||
this.boxSet = boxSet;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author TPEETZ
|
||||
*
|
||||
*/
|
||||
package com.peetz.medien.entity;
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.peetz.medien.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.peetz.medien.entity.AudioCDEntity;
|
||||
import com.peetz.medien.entity.BoxSetEntity;
|
||||
import com.peetz.medien.entity.FilmEntity;
|
||||
|
||||
@Local
|
||||
public interface MedienService
|
||||
{
|
||||
public Collection<AudioCDEntity> getAllCDs();
|
||||
public AudioCDEntity addCD(String title);
|
||||
public Collection<FilmEntity> getAllDVDs();
|
||||
public FilmEntity addDVD(String title);
|
||||
public Collection<BoxSetEntity> getAllBoxSets();
|
||||
public BoxSetEntity addBoxSet(String title);
|
||||
public BoxSetEntity assignBoxSet(BoxSetEntity boxSet, FilmEntity film);
|
||||
public void saveCD(AudioCDEntity audioCD);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.peetz.medien.service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.ejb.Stateless;
|
||||
import javax.ejb.TransactionAttribute;
|
||||
import javax.ejb.TransactionAttributeType;
|
||||
|
||||
import com.peetz.medien.entity.AudioCDEntity;
|
||||
import com.peetz.medien.entity.BoxSetEntity;
|
||||
import com.peetz.medien.entity.FilmEntity;
|
||||
import java.util.ArrayList;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
|
||||
@Stateless(name="MedienService")
|
||||
@TransactionAttribute(TransactionAttributeType.REQUIRED)
|
||||
public class MedienServiceImpl implements MedienService {
|
||||
|
||||
@PersistenceContext(unitName = "kontor")
|
||||
private EntityManager em;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<AudioCDEntity> getAllCDs() {
|
||||
Query query = em.createNamedQuery("AudioCD.findAll");
|
||||
ArrayList<AudioCDEntity> cdList = new ArrayList<AudioCDEntity>(query.getResultList());
|
||||
return cdList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AudioCDEntity addCD(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Collection<FilmEntity> getAllDVDs() {
|
||||
Query query = em.createNamedQuery("Film.findAll");
|
||||
ArrayList<FilmEntity> filmList = new ArrayList<FilmEntity>(query.getResultList());
|
||||
return filmList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FilmEntity addDVD(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BoxSetEntity> getAllBoxSets() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoxSetEntity addBoxSet(String title) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoxSetEntity assignBoxSet(BoxSetEntity boxSet, FilmEntity film) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCD(AudioCDEntity audioCD) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author TPEETZ
|
||||
*
|
||||
*/
|
||||
package com.peetz.medien.service;
|
||||
Reference in New Issue
Block a user