remove obsolete kontor.py
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
|
||||
dependencies {
|
||||
compile 'org.hibernate:hibernate-core:4.3.8.Final'
|
||||
compile 'org.hibernate:hibernate-entitymanager:4.3.8.Final'
|
||||
compile 'org.hsqldb:hsqldb:2.3.0'
|
||||
compile 'ch.qos.logback:logback-core:1.1.2'
|
||||
compile 'ch.qos.logback:logback-classic:1.1.2'
|
||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||
}
|
||||
|
||||
mainClassName = 'com.ibtp.kontor.KontorApp'
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Implementation-Title': 'Kontor Application', 'Implementation-Version': version, 'Main-Class': mainClassName
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ibtp.kontor;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 10.02.2015.
|
||||
*/
|
||||
public class KontorApp {
|
||||
|
||||
private KontorGUI mainframe;
|
||||
|
||||
public KontorApp() {
|
||||
mainframe = new KontorGUI(this);
|
||||
|
||||
mainframe.setVisible(true);
|
||||
}
|
||||
|
||||
public void exitApplication() {
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new KontorApp();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.ibtp.kontor;
|
||||
|
||||
|
||||
import com.ibtp.kontor.comics.view.ComicsMenu;
|
||||
import com.ibtp.kontor.library.view.LibraryMenu;
|
||||
import com.ibtp.kontor.tradingcards.view.TradingCardsMenu;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 11.02.2015.
|
||||
*/
|
||||
public class KontorGUI extends javax.swing.JFrame {
|
||||
|
||||
KontorApp application;
|
||||
JMenuBar menuBar;
|
||||
JMenu menuFile;
|
||||
JMenuItem menuFileExit;
|
||||
|
||||
JMenuItem menuFileStart = new JMenuItem();
|
||||
|
||||
JMenu menuHelp;
|
||||
JMenuItem menuHelpAbout;
|
||||
|
||||
public KontorGUI(KontorApp kontorApp) {
|
||||
application = kontorApp;
|
||||
initComponents();
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
GroupLayout layout = new GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 300, Short.MAX_VALUE)
|
||||
);
|
||||
pack();
|
||||
setTitle("Kontor Application");
|
||||
createMainMenu();
|
||||
//createToolBar();
|
||||
}
|
||||
|
||||
private void createMainMenu() {
|
||||
menuBar = new JMenuBar();
|
||||
menuFile = new JMenu("File");
|
||||
menuFileExit = new JMenuItem("Exit");
|
||||
menuHelp = new JMenu("Help");
|
||||
menuHelpAbout = new JMenuItem("About");
|
||||
setJMenuBar(menuBar);
|
||||
menuBar.add(menuFile);
|
||||
menuFile.add(menuFileExit);
|
||||
menuBar.add(new ComicsMenu());
|
||||
menuBar.add(new LibraryMenu());
|
||||
menuBar.add(new TradingCardsMenu());
|
||||
menuBar.add(menuHelp);
|
||||
menuHelp.add(menuHelpAbout);
|
||||
menuFileExit.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
application.exitApplication();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ArtistEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 16.01.2015.
|
||||
*/
|
||||
interface ArtistDao {
|
||||
|
||||
public ArtistEntity getById(Long id);
|
||||
|
||||
public Collection<ArtistEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<ArtistEntity> findByName(String name);
|
||||
|
||||
public Collection<ArtistEntity> findAll();
|
||||
|
||||
public ArtistEntity addArtist(String name);
|
||||
|
||||
public ArtistEntity store(ArtistEntity entity);
|
||||
|
||||
public void delete(ArtistEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ArtistEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 16.01.2015.
|
||||
*/
|
||||
public class ArtistImpl extends BaseImpl implements ArtistDao {
|
||||
|
||||
public ArtistImpl() {}
|
||||
|
||||
@Override
|
||||
public ArtistEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Artist.findById");
|
||||
query.setParameter("id", id);
|
||||
return (ArtistEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ArtistEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ArtistEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Artist.findAll");
|
||||
return query.getResultList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ArtistEntity> findByName(String name) {
|
||||
Query query = getEntityManager().createNamedQuery("Artist.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArtistEntity addArtist(String name) {
|
||||
ArtistEntity artist = new ArtistEntity(name);
|
||||
artist = store(artist);
|
||||
return artist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArtistEntity store(ArtistEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ArtistEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ComicEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by thomas on 17.01.15.
|
||||
*/
|
||||
interface ComicDao {
|
||||
|
||||
public ComicEntity getById(Long id);
|
||||
|
||||
public Collection<ComicEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<ComicEntity> findByTitle(String title);
|
||||
|
||||
public Collection<ComicEntity> findAll();
|
||||
|
||||
public ComicEntity addComic(String title);
|
||||
|
||||
public ComicEntity store(ComicEntity entity);
|
||||
|
||||
public void delete(ComicEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ComicEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class ComicImpl extends BaseImpl implements ComicDao {
|
||||
|
||||
@Override
|
||||
public ComicEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Comic.findById");
|
||||
query.setParameter("id", id);
|
||||
return (ComicEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ComicEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ComicEntity> findByTitle(String title) {
|
||||
Query query = getEntityManager().createNamedQuery("Comic.findByTitle");
|
||||
query.setParameter("title", title);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ComicEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Comic.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComicEntity addComic(String title) {
|
||||
ComicEntity comicEntity = new ComicEntity();
|
||||
comicEntity.setTitle(title);
|
||||
store(comicEntity);
|
||||
return comicEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComicEntity store(ComicEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ComicEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.IssueEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
interface IssueDao {
|
||||
public IssueEntity getById(Long id);
|
||||
|
||||
public Collection<IssueEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<IssueEntity> findByNumber(String number);
|
||||
|
||||
public Collection<IssueEntity> findAll();
|
||||
|
||||
public IssueEntity store(IssueEntity entity);
|
||||
|
||||
public void delete(IssueEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.IssueEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class IssueImpl extends BaseImpl implements IssueDao {
|
||||
|
||||
@Override
|
||||
public IssueEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Issue.findById");
|
||||
query.setParameter("id", id);
|
||||
return (IssueEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IssueEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IssueEntity> findByNumber(String number) {
|
||||
Query query = getEntityManager().createNamedQuery("Issue.findByNumber");
|
||||
query.setParameter("number", number);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<IssueEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Issue.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IssueEntity store(IssueEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(IssueEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.PublisherEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by thomas on 17.01.15.
|
||||
*/
|
||||
interface PublisherDao {
|
||||
|
||||
public PublisherEntity getById(Long id);
|
||||
|
||||
public Collection<PublisherEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<PublisherEntity> findByName(String name);
|
||||
|
||||
public Collection<PublisherEntity> findAll();
|
||||
|
||||
public PublisherEntity addPublisher(String name);
|
||||
|
||||
public PublisherEntity store(PublisherEntity entity);
|
||||
|
||||
public void delete(PublisherEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.PublisherEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 20.01.2015.
|
||||
*/
|
||||
public class PublisherImpl extends BaseImpl implements PublisherDao {
|
||||
|
||||
@Override
|
||||
public PublisherEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PublisherEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PublisherEntity> findByName(String name) {
|
||||
Query query = getEntityManager().createNamedQuery("Publisher.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PublisherEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Publisher.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublisherEntity addPublisher(String name) {
|
||||
PublisherEntity publisher = new PublisherEntity(name);
|
||||
store(publisher);
|
||||
return publisher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublisherEntity store(PublisherEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(PublisherEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.StoryArcEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
interface StoryArcDao {
|
||||
|
||||
public StoryArcEntity getById(Long id);
|
||||
|
||||
public Collection<StoryArcEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<StoryArcEntity> findByTitle(String title);
|
||||
|
||||
public Collection<StoryArcEntity> findAll();
|
||||
|
||||
public StoryArcEntity store(StoryArcEntity entity);
|
||||
|
||||
public void delete(StoryArcEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.StoryArcEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class StoryArcImpl extends BaseImpl implements StoryArcDao {
|
||||
|
||||
@Override
|
||||
public StoryArcEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<StoryArcEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<StoryArcEntity> findByTitle(String title) {
|
||||
Query query = getEntityManager().createNamedQuery("StoryArc.findByTitle");
|
||||
query.setParameter("title", title);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<StoryArcEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("StoryArc.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StoryArcEntity store(StoryArcEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(StoryArcEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.VolumeEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
interface VolumeDao {
|
||||
|
||||
public VolumeEntity getById(Long id);
|
||||
|
||||
public Collection<VolumeEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<VolumeEntity> findByTitle(String title);
|
||||
|
||||
public Collection<VolumeEntity> findAll();
|
||||
|
||||
public VolumeEntity store(VolumeEntity entity);
|
||||
|
||||
public void delete(VolumeEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.VolumeEntity;
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class VolumeImpl extends BaseImpl implements VolumeDao {
|
||||
|
||||
@Override
|
||||
public VolumeEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Volume.findById");
|
||||
query.setParameter("id", id);
|
||||
return (VolumeEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VolumeEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VolumeEntity> findByTitle(String title) {
|
||||
Query query = getEntityManager().createNamedQuery("Volume.findByTitle");
|
||||
query.setParameter("title", title);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<VolumeEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Volume.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeEntity store(VolumeEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(VolumeEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 16.01.2015.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Artist.findAll", query="SELECT a from ArtistEntity as a"),
|
||||
@NamedQuery(name="Artist.findByName", query="SELECT a from ArtistEntity as a WHERE a.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="ARTIST")
|
||||
public class ArtistEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Collection<IssueEntity> writtenIssues = new ArrayList<IssueEntity>();
|
||||
|
||||
private Collection<IssueEntity> inkedIssues = new ArrayList<IssueEntity>();
|
||||
|
||||
private Collection<IssueEntity> penciledIssues = new ArrayList<IssueEntity>();
|
||||
|
||||
public ArtistEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
public ArtistEntity() {}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
String getName() { return name; }
|
||||
|
||||
void setName(String name) { this.name = name; }
|
||||
|
||||
public void setWrittenIssues(Collection<IssueEntity> writtenIssues) { this.writtenIssues = writtenIssues; }
|
||||
|
||||
@OneToMany(mappedBy="writer", cascade=CascadeType.REMOVE)
|
||||
public Collection<IssueEntity> getWrittenIssues() {
|
||||
return writtenIssues;
|
||||
}
|
||||
|
||||
public void setInkedIssues(Collection<IssueEntity> inkedIssues) { this.inkedIssues = inkedIssues; }
|
||||
|
||||
@OneToMany(mappedBy="inker", cascade=CascadeType.REMOVE)
|
||||
public Collection<IssueEntity> getInkedIssues() {
|
||||
return inkedIssues;
|
||||
}
|
||||
|
||||
public void setPenciledIssues(Collection<IssueEntity> penciledIssues) { this.penciledIssues = penciledIssues; }
|
||||
|
||||
@OneToMany(mappedBy="penciler", cascade=CascadeType.REMOVE)
|
||||
public Collection<IssueEntity> getPenciledIssues() {
|
||||
return penciledIssues;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Artist[" + "id=" + getId() + ",name=" + getName() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by thomas on 17.01.15.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Comic.findAll", query="SELECT c from ComicEntity as c"),
|
||||
@NamedQuery(name="Comic.findByTitle", query="SELECT c from ComicEntity as c WHERE c.title = :title")
|
||||
})
|
||||
@Entity
|
||||
@Table(name = "COMIC")
|
||||
public class ComicEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Boolean completed;
|
||||
|
||||
private Boolean currentOrder;
|
||||
|
||||
private Collection<IssueEntity> issues = new ArrayList<IssueEntity>();
|
||||
|
||||
private Collection<StoryArcEntity> storyArc = new ArrayList<StoryArcEntity>();
|
||||
|
||||
private Collection<VolumeEntity> volumes = new ArrayList<VolumeEntity>();
|
||||
|
||||
private PublisherEntity publisher;
|
||||
|
||||
@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; }
|
||||
|
||||
@Column
|
||||
public Boolean getCompleted() { return completed; }
|
||||
|
||||
public Boolean isCompleted() { return completed; }
|
||||
|
||||
public void setCompleted(Boolean completed) { this.completed = completed; }
|
||||
|
||||
@Column
|
||||
public Boolean getCurrentOrder() { return currentOrder; }
|
||||
|
||||
public Boolean isCurrentOrder() { return currentOrder; }
|
||||
|
||||
public void setCurrentOrder(Boolean currentOrder) { this.currentOrder = currentOrder; }
|
||||
|
||||
public void setIssues(Collection<IssueEntity> issues) { this.issues = issues; }
|
||||
|
||||
@OneToMany(mappedBy="comic", cascade=CascadeType.REMOVE)
|
||||
public Collection<IssueEntity> getIssues() { return issues; }
|
||||
|
||||
public void setStoryArc(Collection<StoryArcEntity> storyArc) { this.storyArc = storyArc; }
|
||||
|
||||
@OneToMany(mappedBy="comic", cascade=CascadeType.REMOVE)
|
||||
public Collection<StoryArcEntity> getStoryArc() { return storyArc; }
|
||||
|
||||
public void setVolumes(Collection<VolumeEntity> volumes) { this.volumes = volumes; }
|
||||
|
||||
@OneToMany(mappedBy="comic", cascade=CascadeType.REMOVE)
|
||||
public Collection<VolumeEntity> getVolumes() { return volumes; }
|
||||
|
||||
@ManyToOne
|
||||
public PublisherEntity getPublisher() { return publisher; }
|
||||
|
||||
public void setPublisher(PublisherEntity publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by thomas on 18.01.15.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Issue.findAll", query="SELECT i from IssueEntity as i"),
|
||||
@NamedQuery(name="Issue.findByNumber", query="SELECT i from IssueEntity as i WHERE i.number = :number")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "ISSUE")
|
||||
public class IssueEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String number;
|
||||
|
||||
private Boolean completed;
|
||||
|
||||
private ComicEntity comic;
|
||||
|
||||
private ArtistEntity writer;
|
||||
|
||||
private ArtistEntity inker;
|
||||
|
||||
private ArtistEntity penciler;
|
||||
|
||||
private StoryArcEntity storyArc;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
public Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
public String getNumber() { return number; }
|
||||
|
||||
public void setNumber(String number) { this.number = number; }
|
||||
|
||||
@Column
|
||||
public Boolean getCompleted() { return completed; }
|
||||
public Boolean isCompleted() { return completed; }
|
||||
|
||||
public void setCompleted(Boolean completed) { this.completed = completed; }
|
||||
|
||||
public void setComic(ComicEntity comic) { this.comic = comic; }
|
||||
|
||||
@ManyToOne
|
||||
public ComicEntity getComic() { return comic; }
|
||||
|
||||
public void setWriter(ArtistEntity writer) { this.writer = writer; }
|
||||
|
||||
@ManyToOne
|
||||
public ArtistEntity getWriter() { return writer; }
|
||||
|
||||
public void setInker(ArtistEntity inker) { this.inker = inker; }
|
||||
|
||||
@ManyToOne
|
||||
public ArtistEntity getInker() { return inker; }
|
||||
|
||||
public void setPenciler(ArtistEntity penciler) { this.penciler = penciler; }
|
||||
|
||||
@ManyToOne
|
||||
public ArtistEntity getPenciler() { return penciler; }
|
||||
|
||||
public void setStoryArc(StoryArcEntity storyArc) { this.storyArc = storyArc; }
|
||||
|
||||
@ManyToOne
|
||||
public StoryArcEntity getStoryArc() { return storyArc; }
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by thomas on 17.01.15.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Publisher.findAll", query="SELECT p from PublisherEntity as p"),
|
||||
@NamedQuery(name="Publisher.findByName", query="SELECT p from PublisherEntity as p WHERE p.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "PUBLISHER")
|
||||
public class PublisherEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Collection<ComicEntity> comic = new ArrayList<ComicEntity>();
|
||||
|
||||
public PublisherEntity() {}
|
||||
|
||||
public PublisherEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@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; }
|
||||
|
||||
void setName(String name) { this.name = name; }
|
||||
|
||||
public void setComic(Collection<ComicEntity> comic) { this.comic = comic; }
|
||||
|
||||
@OneToMany(mappedBy="publisher", cascade=CascadeType.REMOVE)
|
||||
public Collection<ComicEntity> getComic() { return comic; }
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by thomas on 17.01.15.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="StoryArc.findAll", query="SELECT s from StoryArcEntity as s"),
|
||||
@NamedQuery(name="StoryArc.findByTitle", query="SELECT s from StoryArcEntity as s WHERE s.title = :title")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "STORYARC")
|
||||
public class StoryArcEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Collection<IssueEntity> issues = new ArrayList<IssueEntity>();
|
||||
|
||||
private ComicEntity comic;
|
||||
|
||||
@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; }
|
||||
|
||||
public void setIssues(Collection<IssueEntity> issues) { this.issues = issues; }
|
||||
|
||||
@OneToMany(mappedBy="storyArc", cascade=CascadeType.REMOVE)
|
||||
public Collection<IssueEntity> getIssues() { return issues; }
|
||||
|
||||
public void setComic(ComicEntity comic) { this.comic = comic; }
|
||||
|
||||
@ManyToOne
|
||||
public ComicEntity getComic() { return comic; }
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.ibtp.kontor.comics.entity;
|
||||
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Volume.findAll", query="SELECT v from VolumeEntity as v"),
|
||||
@NamedQuery(name="Volume.findByTitle", query="SELECT v from VolumeEntity as v WHERE v.title = :title")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "VOLUME")
|
||||
public class VolumeEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private ComicEntity comic;
|
||||
|
||||
@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 ComicEntity getComic() { return comic; }
|
||||
|
||||
public void setComic(ComicEntity comic) { this.comic = comic; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ibtp.kontor.comics.view;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 12.02.2015.
|
||||
*/
|
||||
public class ComicsMenu extends JMenu {
|
||||
|
||||
public ComicsMenu() {
|
||||
super("Comics");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ibtp.kontor.dal;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 16.01.2015.
|
||||
*/
|
||||
public class BaseImpl {
|
||||
|
||||
protected BaseImpl() {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass().getName());
|
||||
logger.info("BaseImpl started");
|
||||
}
|
||||
|
||||
protected EntityManager getEntityManager() {
|
||||
return DatabaseManager.getDatabase().getEntityManager();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ibtp.kontor.dal;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 21.01.2015.
|
||||
*/
|
||||
public interface Database {
|
||||
|
||||
public EntityManager getEntityManager();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ibtp.kontor.dal;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 22.01.2015.
|
||||
*/
|
||||
public class DatabaseManager {
|
||||
|
||||
private static Database database;
|
||||
private static Logger logger = LoggerFactory.getLogger(DatabaseManager.class.getName());
|
||||
|
||||
public static Database getDatabase() {
|
||||
logger.info("return " + database.toString());
|
||||
return database;
|
||||
}
|
||||
|
||||
public static void setDatabase(Database database) {
|
||||
logger.info("set " + database.toString());
|
||||
DatabaseManager.database = database;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.ibtp.kontor.dal;
|
||||
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hsqldb.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.persistence.spi.PersistenceProvider;
|
||||
import javax.persistence.spi.PersistenceProviderResolver;
|
||||
import javax.persistence.spi.PersistenceProviderResolverHolder;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
public class LocalDatabase implements Database {
|
||||
|
||||
private static Server server;
|
||||
private static EntityManagerFactory factory;
|
||||
private static EntityManager em;
|
||||
private static Logger logger = LoggerFactory.getLogger(LocalDatabase.class.getName());
|
||||
|
||||
private LocalDatabase() {
|
||||
logger.info("LocalDatabase started");
|
||||
}
|
||||
|
||||
private static void assureDatabaseRunning() {
|
||||
if (LocalDatabase.server == null) {
|
||||
LocalDatabase.startDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
private static void startDatabase() {
|
||||
Logger logger = LoggerFactory.getLogger(LocalDatabase.class.getName());
|
||||
logger.info("startDatabase as kontor in hsqldb_databases/kontor");
|
||||
LocalDatabase.server = new Server();
|
||||
LocalDatabase.server.setAddress("localhost");
|
||||
LocalDatabase.server.setDatabaseName(0, "kontor");
|
||||
LocalDatabase.server.setDatabasePath(0, "file:hsqldb_databases/kontor");
|
||||
LocalDatabase.server.setPort(2345);
|
||||
LocalDatabase.server.setTrace(true);
|
||||
LocalDatabase.server.setLogWriter(new PrintWriter(System.out));
|
||||
LocalDatabase.server.start();
|
||||
}
|
||||
|
||||
private static void stopDatabase() {
|
||||
server.shutdown();
|
||||
}
|
||||
private static EntityManagerFactory getFactory() {
|
||||
if (LocalDatabase.factory == null) {
|
||||
LocalDatabase.assureDatabaseRunning();
|
||||
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new PersistenceProviderResolver() {
|
||||
private final List<PersistenceProvider> providers_ = Arrays.asList((PersistenceProvider) new HibernatePersistenceProvider());
|
||||
|
||||
@Override
|
||||
public void clearCachedProviders() {
|
||||
// Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PersistenceProvider> getPersistenceProviders() {
|
||||
return providers_;
|
||||
}
|
||||
});
|
||||
LocalDatabase.factory = Persistence.createEntityManagerFactory("com.ibtp.kontor");
|
||||
logger.info("EntityManagerFactory(com.ibtp.kontor) created");
|
||||
}
|
||||
return LocalDatabase.factory;
|
||||
}
|
||||
|
||||
private static EntityManager getSingleEntityManager() {
|
||||
return LocalDatabase.em;
|
||||
}
|
||||
|
||||
private static void setSingleEntityManager(EntityManager manager) {
|
||||
LocalDatabase.em = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManager getEntityManager() {
|
||||
if (getSingleEntityManager() == null) {
|
||||
setSingleEntityManager(getFactory().createEntityManager());
|
||||
logger.info("EntityManager created");
|
||||
}
|
||||
return getSingleEntityManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String serverMessage;
|
||||
if (LocalDatabase.server == null) {
|
||||
serverMessage = "server:null";
|
||||
} else {
|
||||
serverMessage = LocalDatabase.server.toString();
|
||||
}
|
||||
return LocalDatabase.class.getName() + " " + serverMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.library.entity.ArticleEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
interface ArticleDao {
|
||||
|
||||
public ArticleEntity getById(Long id);
|
||||
|
||||
public List<ArticleEntity> findByIds(List<Long> ids);
|
||||
|
||||
public List<ArticleEntity> findAll();
|
||||
|
||||
public List<ArticleEntity> findByTitle(String title);
|
||||
|
||||
public ArticleEntity store(ArticleEntity entity);
|
||||
|
||||
public void delete(ArticleEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.library.entity.ArticleEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
public class ArticleImpl extends BaseImpl implements ArticleDao {
|
||||
|
||||
@Override
|
||||
public ArticleEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Article.findById");
|
||||
query.setParameter("id", id);
|
||||
return (ArticleEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Article.findAll");
|
||||
//noinspection unchecked
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArticleEntity> findByTitle(String title) {
|
||||
Query query = getEntityManager().createNamedQuery("Article.findByTitle");
|
||||
query.setParameter("title", title);
|
||||
//noinspection unchecked
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public ArticleEntity addArticle(String title) {
|
||||
ArticleEntity entity = new ArticleEntity(title);
|
||||
store(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArticleEntity store(ArticleEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ArticleEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.library.entity.AuthorEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
interface AuthorDao {
|
||||
|
||||
public AuthorEntity getById(Long id);
|
||||
|
||||
public List<AuthorEntity> findByIds(List<Long> ids);
|
||||
|
||||
public List<AuthorEntity> findByName(String name);
|
||||
|
||||
public List<AuthorEntity> findAll();
|
||||
|
||||
public AuthorEntity addAuthor(String name);
|
||||
|
||||
public AuthorEntity store(AuthorEntity entity);
|
||||
|
||||
public void delete(AuthorEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.library.entity.AuthorEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by thomas on 23.01.15.
|
||||
*/
|
||||
public class AuthorImpl extends BaseImpl implements AuthorDao {
|
||||
|
||||
public AuthorImpl() {}
|
||||
|
||||
@Override
|
||||
public AuthorEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Author.findById");
|
||||
query.setParameter("id", id);
|
||||
return (AuthorEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorEntity> findByName(String name) {
|
||||
Query query = getEntityManager().createNamedQuery("Author.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Author.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorEntity addAuthor(String name) {
|
||||
AuthorEntity author = new AuthorEntity(name);
|
||||
store(author);
|
||||
return author;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthorEntity store(AuthorEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(AuthorEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.library.entity.BookEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
interface BookDao {
|
||||
|
||||
public BookEntity getById(Long id);
|
||||
|
||||
public Collection<BookEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<BookEntity> findByName(String name);
|
||||
|
||||
public BookEntity store(BookEntity entity);
|
||||
|
||||
public void delete(BookEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.library.entity.BookEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class BookImpl extends BaseImpl implements BookDao {
|
||||
|
||||
@Override
|
||||
public BookEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BookEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BookEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookEntity store(BookEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(BookEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.library.entity.FileEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
interface FileDao {
|
||||
|
||||
public FileEntity getById(Long id);
|
||||
|
||||
public Collection<FileEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<FileEntity> findByName(String name);
|
||||
|
||||
public FileEntity store(FileEntity entity);
|
||||
|
||||
public void delete(FileEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.library.entity.FileEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class FileImpl extends BaseImpl implements FileDao {
|
||||
|
||||
@Override
|
||||
public FileEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FileEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FileEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileEntity store(FileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(FileEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.library.entity.TitleEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
interface TitleDao {
|
||||
|
||||
public TitleEntity getById(Long id);
|
||||
|
||||
public Collection<TitleEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<TitleEntity> findByName(String name);
|
||||
|
||||
public TitleEntity store(TitleEntity entity);
|
||||
|
||||
public void delete(TitleEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.library.entity.TitleEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class TitleImpl extends BaseImpl implements TitleDao {
|
||||
|
||||
@Override
|
||||
public TitleEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TitleEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TitleEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TitleEntity store(TitleEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TitleEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ibtp.kontor.library.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 23.01.2015.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Article.findAll", query="SELECT a from ArticleEntity as a"),
|
||||
@NamedQuery(name="Article.findByTitle", query="SELECT a from ArticleEntity as a WHERE a.title = :title")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name = "ARTICLE")
|
||||
public class ArticleEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private AuthorEntity author;
|
||||
|
||||
public ArticleEntity() {}
|
||||
|
||||
public ArticleEntity(String title) {
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public AuthorEntity getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(AuthorEntity author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ibtp.kontor.library.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 23.01.2015.
|
||||
*/
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Author.findAll", query="SELECT a from AuthorEntity as a"),
|
||||
@NamedQuery(name="Author.findById", query="SELECT a from AuthorEntity as a WHERE a.id = :id"),
|
||||
@NamedQuery(name="Author.findByName", query="SELECT a from AuthorEntity as a WHERE a.name = :name")
|
||||
})
|
||||
@Entity
|
||||
@Table(name="AUTHOR")
|
||||
public class AuthorEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Collection<BookEntity> books = new ArrayList<BookEntity>();
|
||||
|
||||
private Collection<ArticleEntity> articles = new ArrayList<ArticleEntity>();
|
||||
|
||||
public AuthorEntity() {}
|
||||
|
||||
public AuthorEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@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; }
|
||||
|
||||
void setName(String name) { this.name = name; }
|
||||
|
||||
@OneToMany(mappedBy="author", cascade=CascadeType.REMOVE)
|
||||
public Collection<BookEntity> getBooks() {
|
||||
return books;
|
||||
}
|
||||
|
||||
public void setBooks(Collection<BookEntity> books) {
|
||||
this.books = books;
|
||||
}
|
||||
|
||||
@OneToMany(mappedBy="author", cascade=CascadeType.REMOVE)
|
||||
public Collection<ArticleEntity> getArticles() {
|
||||
return articles;
|
||||
}
|
||||
|
||||
public void setArticles(Collection<ArticleEntity> articles) {
|
||||
this.articles = articles;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.ibtp.kontor.library.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 23.01.2015.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "BOOK")
|
||||
public class BookEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
private AuthorEntity author;
|
||||
|
||||
private String publisher;
|
||||
|
||||
private String isbn;
|
||||
|
||||
private Long page;
|
||||
|
||||
private String edition;
|
||||
|
||||
public BookEntity() {}
|
||||
|
||||
public BookEntity(String title) {
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* unused */
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
public AuthorEntity getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(AuthorEntity author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getIsbn() {
|
||||
return isbn;
|
||||
}
|
||||
|
||||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
|
||||
@Column
|
||||
public Long getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Long page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getEdition() {
|
||||
return edition;
|
||||
}
|
||||
|
||||
public void setEdition(String edition) {
|
||||
this.edition = edition;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getPublisher() {
|
||||
return publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(String publisher) {
|
||||
this.publisher = publisher;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ibtp.kontor.library.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 23.01.2015.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "FILE")
|
||||
public class FileEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
public FileEntity() {}
|
||||
|
||||
public FileEntity(String title) {
|
||||
setTitle(title);
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* unused */
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.library.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 23.01.2015.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "TITLE")
|
||||
public class TitleEntity {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String title;
|
||||
|
||||
@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; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ibtp.kontor.library.view;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 12.02.2015.
|
||||
*/
|
||||
public class LibraryMenu extends JMenu {
|
||||
|
||||
public LibraryMenu() {
|
||||
super("Library");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.BaseSetEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface BaseSetDao {
|
||||
|
||||
public BaseSetEntity getById(Long id);
|
||||
|
||||
public Collection<BaseSetEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<BaseSetEntity> findByName(String name);
|
||||
|
||||
public BaseSetEntity store(BaseSetEntity entity);
|
||||
|
||||
public void delete(BaseSetEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.BaseSetEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class BaseSetImpl extends BaseImpl implements BaseSetDao {
|
||||
|
||||
@Override
|
||||
public BaseSetEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("BaseSet.findById");
|
||||
query.setParameter("id", id);
|
||||
return (BaseSetEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BaseSetEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<BaseSetEntity> findByName(String name) {
|
||||
Query query = getEntityManager().createNamedQuery("BaseSet.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseSetEntity store(BaseSetEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(BaseSetEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.InsertEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface InsertDao {
|
||||
|
||||
public InsertEntity getById(Long id);
|
||||
|
||||
public Collection<InsertEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<InsertEntity> findByName(String name);
|
||||
|
||||
public InsertEntity store(InsertEntity entity);
|
||||
|
||||
public void delete(InsertEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.InsertEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class InsertImpl extends BaseImpl implements InsertDao {
|
||||
|
||||
@Override
|
||||
public InsertEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<InsertEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<InsertEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InsertEntity store(InsertEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(InsertEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.BaseSetEntity;
|
||||
import com.ibtp.kontor.tradingcards.entity.ManufacturerEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
interface ManufacturerDao {
|
||||
|
||||
public ManufacturerEntity getById(Long id);
|
||||
|
||||
public Collection<ManufacturerEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<ManufacturerEntity> findByName(String name);
|
||||
|
||||
public ManufacturerEntity assignBaseSet(ManufacturerEntity manufacturer, BaseSetEntity baseSet);
|
||||
|
||||
public ManufacturerEntity addManufacturer(String name);
|
||||
|
||||
public ManufacturerEntity store(ManufacturerEntity entity);
|
||||
|
||||
public void delete(ManufacturerEntity entity);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.BaseSetEntity;
|
||||
import com.ibtp.kontor.tradingcards.entity.ManufacturerEntity;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
public class ManufacturerImpl extends BaseImpl implements ManufacturerDao {
|
||||
|
||||
@Override
|
||||
public ManufacturerEntity getById(Long id) {
|
||||
Query q = getEntityManager().createNamedQuery("Manufacturer.findById");
|
||||
q.setParameter("id", id);
|
||||
return (ManufacturerEntity)q.getSingleResult();
|
||||
}
|
||||
|
||||
@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 = getEntityManager().createNamedQuery("Manufacturer.findByName");
|
||||
q.setParameter("name", name);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@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 addManufacturer(String name) {
|
||||
ManufacturerEntity manufacturer = new ManufacturerEntity(name);
|
||||
store(manufacturer);
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManufacturerEntity store(ManufacturerEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ManufacturerEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.ParallelSetEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface ParallelSetDao {
|
||||
|
||||
public ParallelSetEntity getById(Long id);
|
||||
|
||||
public Collection<ParallelSetEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<ParallelSetEntity> findByName(String name);
|
||||
|
||||
public ParallelSetEntity store(ParallelSetEntity entity);
|
||||
|
||||
public void delete(ParallelSetEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.ParallelSetEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class ParallelSetImpl extends BaseImpl implements ParallelSetDao {
|
||||
|
||||
@Override
|
||||
public ParallelSetEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ParallelSetEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ParallelSetEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParallelSetEntity store(ParallelSetEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ParallelSetEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.PlayerEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface PlayerDao {
|
||||
|
||||
public PlayerEntity getById(Long id);
|
||||
|
||||
public Collection<PlayerEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<PlayerEntity> findByName(String name);
|
||||
|
||||
public PlayerEntity addPlayer(String name);
|
||||
|
||||
public PlayerEntity store(PlayerEntity entity);
|
||||
|
||||
public void delete(PlayerEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.PlayerEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class PlayerImpl extends BaseImpl implements PlayerDao {
|
||||
|
||||
@Override
|
||||
public PlayerEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PlayerEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PlayerEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerEntity addPlayer(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerEntity store(PlayerEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(PlayerEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.PositionEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface PositionDao {
|
||||
|
||||
public PositionEntity getById(Long id);
|
||||
|
||||
public Collection<PositionEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<PositionEntity> findByName(String name);
|
||||
|
||||
public Collection<PositionEntity> findAll();
|
||||
|
||||
public PositionEntity addPosition(String name);
|
||||
|
||||
public PositionEntity store(PositionEntity entity);
|
||||
|
||||
public void delete(PositionEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.PositionEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class PositionImpl extends BaseImpl implements PositionDao {
|
||||
|
||||
@Override
|
||||
public PositionEntity getById(Long id) {
|
||||
Query q = getEntityManager().createNamedQuery("Position.findById");
|
||||
q.setParameter("id", id);
|
||||
return (PositionEntity)q.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PositionEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PositionEntity> findByName(String name) {
|
||||
Query q = getEntityManager().createNamedQuery("Position.findByName");
|
||||
q.setParameter("name", name);
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PositionEntity> findAll() {
|
||||
Query q = getEntityManager().createNamedQuery("Position.findAll");
|
||||
return q.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionEntity addPosition(String name) {
|
||||
PositionEntity position = new PositionEntity(name);
|
||||
store(position);
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PositionEntity store(PositionEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(PositionEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.SportCardEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
interface SportCardDao {
|
||||
|
||||
public SportCardEntity getById(Long id);
|
||||
|
||||
public Collection<SportCardEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<SportCardEntity> findByName(String name);
|
||||
|
||||
public SportCardEntity store(SportCardEntity entity);
|
||||
|
||||
public void delete(SportCardEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.SportCardEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class SportCardImpl extends BaseImpl implements SportCardDao {
|
||||
|
||||
@Override
|
||||
public SportCardEntity getById(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SportCardEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SportCardEntity> findByName(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SportCardEntity store(SportCardEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SportCardEntity entity) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
interface SportDao {
|
||||
public SportEntity getById(Long id);
|
||||
|
||||
public Collection<SportEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<SportEntity> findByName(String name);
|
||||
|
||||
public Collection<SportEntity> findAll();
|
||||
|
||||
public SportEntity addSport(String name);
|
||||
|
||||
public SportEntity store(SportEntity entity);
|
||||
|
||||
public void delete(SportEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tpeetz
|
||||
*/
|
||||
public class SportImpl extends BaseImpl implements SportDao {
|
||||
|
||||
@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 = getEntityManager().createNamedQuery("Sport.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<SportEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Sport.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SportEntity addSport(String name) {
|
||||
SportEntity sport = new SportEntity(name);
|
||||
store(sport);
|
||||
return sport;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SportEntity store(SportEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(SportEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
import com.ibtp.kontor.tradingcards.entity.TeamEntity;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
interface TeamDao {
|
||||
public TeamEntity getById(Long id);
|
||||
|
||||
public Collection<TeamEntity> findByIds(List<Long> ids);
|
||||
|
||||
public Collection<TeamEntity> findByName(String name);
|
||||
|
||||
public Collection<TeamEntity> findAll();
|
||||
|
||||
public TeamEntity addTeam(String name, SportEntity sport);
|
||||
|
||||
public TeamEntity store(TeamEntity entity);
|
||||
|
||||
public void delete(TeamEntity entity);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.BaseImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
import com.ibtp.kontor.tradingcards.entity.TeamEntity;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
public class TeamImpl extends BaseImpl implements TeamDao {
|
||||
|
||||
@Override
|
||||
public TeamEntity getById(Long id) {
|
||||
Query query = getEntityManager().createNamedQuery("Team.findById");
|
||||
query.setParameter("id", id);
|
||||
return (TeamEntity)query.getSingleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TeamEntity> findByIds(List<Long> ids) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TeamEntity> findByName(String name) {
|
||||
Query query = getEntityManager().createNamedQuery("Team.findByName");
|
||||
query.setParameter("name", name);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TeamEntity> findAll() {
|
||||
Query query = getEntityManager().createNamedQuery("Team.findAll");
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeamEntity addTeam(String name, SportEntity sport) {
|
||||
TeamEntity team = new TeamEntity(name);
|
||||
team.setSport(sport);
|
||||
store(team);
|
||||
return team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TeamEntity store(TeamEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.persist(entity);
|
||||
em.getTransaction().commit();
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(TeamEntity entity) {
|
||||
EntityManager em = getEntityManager();
|
||||
em.getTransaction().begin();
|
||||
em.remove(entity);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.ibtp.kontor.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.ibtp.kontor.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;
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.ibtp.kontor.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>();
|
||||
|
||||
public ManufacturerEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
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.ibtp.kontor.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ibtp.kontor.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;
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.ibtp.kontor.tradingcards.entity;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@NamedQueries({
|
||||
@NamedQuery(name="Position.findAll", query="SELECT m from PositionEntity as m"),
|
||||
@NamedQuery(name="Position.findByName", query="SELECT m from PositionEntity as m WHERE m.name = :name")
|
||||
})
|
||||
|
||||
@Entity
|
||||
@Table(name="POSITION")
|
||||
public class PositionEntity {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
private String shortName;
|
||||
private SportEntity sport;
|
||||
|
||||
public PositionEntity() {}
|
||||
|
||||
public PositionEntity(String name) { setName(name); }
|
||||
|
||||
@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.ibtp.kontor.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,75 @@
|
||||
package com.ibtp.kontor.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>();
|
||||
|
||||
public SportEntity() {}
|
||||
|
||||
public SportEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
Long getId() { return id; }
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void setId(Long id) { this.id = id; }
|
||||
|
||||
@Column
|
||||
String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Sport[" + "id=" + getId() + ",name=" + getName() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.ibtp.kontor.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;
|
||||
|
||||
public TeamEntity() {}
|
||||
|
||||
public TeamEntity(String name) {
|
||||
setName(name);
|
||||
}
|
||||
|
||||
@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; }
|
||||
|
||||
void setName(String name) { this.name = name; }
|
||||
|
||||
@ManyToOne
|
||||
public SportEntity getSport() { return sport; }
|
||||
|
||||
public void setSport(SportEntity sport) { this.sport = sport; }
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.ibtp.kontor.tradingcards.view;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 13.02.2015.
|
||||
*/
|
||||
public class TradingCardsMenu extends JMenu {
|
||||
|
||||
public TradingCardsMenu() {
|
||||
super("TradingCards");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
|
||||
version="2.0">
|
||||
<persistence-unit name="com.ibtp.kontor" >
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
<class>com.ibtp.kontor.comics.entity.ArtistEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.ComicEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.IssueEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.StoryArcEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.VolumeEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.PublisherEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.AuthorEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.ArticleEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.BookEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.FileEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.TitleEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.SportEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.TeamEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.PositionEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.PlayerEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.ManufacturerEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.BaseSetEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.InsertEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.ParallelSetEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.SportCardEntity</class>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
|
||||
<property name="javax.persistence.jdbc.user" value="sa"/>
|
||||
<property name="javax.persistence.jdbc.password" value=""/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:hsql://localhost:2345/kontor;shutdown=true;hsqldb.write_delay=false"/>
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
|
||||
<property name="hibernate.show_sql" value="true"/>
|
||||
<property name="hibernate.max_fetch_depth" value="3"/>
|
||||
<property name="hibernate.hbm2ddl.auto" value="update"/>
|
||||
<property name="hsqldb.write_delay" value="false"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>c:/kontor.log</file>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<FileNamePattern>c:/kontor.%i.log.zip</FileNamePattern>
|
||||
<MinIndex>1</MinIndex>
|
||||
<MaxIndex>10</MaxIndex>
|
||||
</rollingPolicy>
|
||||
|
||||
<triggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>2MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
|
||||
</appender>
|
||||
|
||||
<logger name="org.hibernate.type" level="ALL" />
|
||||
<logger name="org.hibernate" level="DEBUG" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ibtp.kontor.comics;
|
||||
|
||||
import com.ibtp.kontor.comics.dal.PublisherImpl;
|
||||
import com.ibtp.kontor.comics.entity.PublisherEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class CollectionTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
PublisherImpl publisherImpl = new PublisherImpl();
|
||||
Collection<PublisherEntity> publisherEntities = publisherImpl.findAll();
|
||||
for (Iterator<PublisherEntity> iterator = publisherEntities.iterator(); iterator.hasNext(); ) {
|
||||
PublisherEntity next = iterator.next();
|
||||
publisherImpl.delete(next);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddPublishers() {
|
||||
String publisherName = "Bongo Comics";
|
||||
PublisherImpl publisherImpl = new PublisherImpl();
|
||||
publisherImpl.addPublisher("Bongo Comics");
|
||||
publisherImpl.addPublisher("Marvel");
|
||||
Collection<PublisherEntity> publisherList = publisherImpl.findAll();
|
||||
Assert.assertEquals(2, publisherList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ArtistEntity;
|
||||
import com.ibtp.kontor.dal.*;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class ArtistImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtistAddAndDelete() {
|
||||
String artistName = "testArtistAddAndDelete";
|
||||
ArtistImpl artistImpl = new ArtistImpl();
|
||||
artistImpl.addArtist(artistName);
|
||||
Collection<ArtistEntity> resultList = artistImpl.findByName(artistName);
|
||||
Assert.assertNotNull(resultList);
|
||||
Assert.assertTrue(resultList.size() > 0);
|
||||
ArtistEntity artist = (ArtistEntity)(resultList.toArray()[0]);
|
||||
artistImpl.delete(artist);
|
||||
resultList = artistImpl.findByName(artistName);
|
||||
Assert.assertNotNull(resultList);
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArtistFindAll() {
|
||||
ArtistImpl artistImpl = new ArtistImpl();
|
||||
Collection<ArtistEntity> artistList = artistImpl.findAll();
|
||||
Assert.assertNotNull(artistList);
|
||||
Assert.assertEquals(0, artistList.size());
|
||||
artistImpl.addArtist("testArtistFindAll1");
|
||||
artistImpl.addArtist("testArtistFindAll2");
|
||||
artistImpl.addArtist("testArtistFindAll3");
|
||||
artistList = artistImpl.findAll();
|
||||
Assert.assertNotNull(artistList);
|
||||
Assert.assertEquals(3, artistList.size());
|
||||
for (Iterator<ArtistEntity> iterator = artistList.iterator(); iterator.hasNext(); ) {
|
||||
ArtistEntity next = iterator.next();
|
||||
artistImpl.delete(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.ComicEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class ComicImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComicAddAndDelete() {
|
||||
String comicTitle = "Comic1";
|
||||
ComicImpl comicImpl = new ComicImpl();
|
||||
comicImpl.addComic(comicTitle);
|
||||
Collection<ComicEntity> comicList = comicImpl.findByTitle(comicTitle);
|
||||
Assert.assertNotNull(comicList);
|
||||
Assert.assertEquals(1, comicList.size());
|
||||
comicImpl.delete((ComicEntity) comicList.toArray()[0]);
|
||||
comicList = comicImpl.findByTitle(comicTitle);
|
||||
Assert.assertNotNull(comicList);
|
||||
Assert.assertEquals(0, comicList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComicFindAll() {
|
||||
ComicImpl comicImpl = new ComicImpl();
|
||||
comicImpl.addComic("Comic1");
|
||||
comicImpl.addComic("Comic2");
|
||||
comicImpl.addComic("Comic3");
|
||||
Collection<ComicEntity> comicList = comicImpl.findAll();
|
||||
Assert.assertNotNull(comicList);
|
||||
Assert.assertEquals(3, comicList.size());
|
||||
for (Iterator<ComicEntity> iterator = comicList.iterator(); iterator.hasNext(); ) {
|
||||
ComicEntity next = iterator.next();
|
||||
comicImpl.delete(next);
|
||||
}
|
||||
comicList = comicImpl.findAll();
|
||||
Assert.assertNotNull(comicList);
|
||||
Assert.assertEquals(0, comicList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.IssueEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class IssueImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIssueAddAndDelete() {
|
||||
String issueNumber = "42";
|
||||
IssueImpl issueImpl = new IssueImpl();
|
||||
IssueEntity issue = new IssueEntity();
|
||||
issue.setNumber(issueNumber);
|
||||
issueImpl.store(issue);
|
||||
Collection<IssueEntity> issueList = issueImpl.findByNumber(issueNumber);
|
||||
Assert.assertNotNull(issueList);
|
||||
Assert.assertEquals(1, issueList.size());
|
||||
issueImpl.delete(issue);
|
||||
issueList = issueImpl.findByNumber(issueNumber);
|
||||
Assert.assertNotNull(issueList);
|
||||
Assert.assertEquals(0, issueList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIssueFindAll() {
|
||||
IssueImpl issueImpl = new IssueImpl();
|
||||
IssueEntity issue1 = new IssueEntity();
|
||||
issue1.setNumber("issue1");
|
||||
IssueEntity issue2 = new IssueEntity();
|
||||
issue1.setNumber("issue2");
|
||||
IssueEntity issue3 = new IssueEntity();
|
||||
issue1.setNumber("issue3");
|
||||
issueImpl.store(issue1);
|
||||
issueImpl.store(issue2);
|
||||
issueImpl.store(issue3);
|
||||
Collection<IssueEntity> issueList = issueImpl.findAll();
|
||||
Assert.assertNotNull(issueList);
|
||||
Assert.assertEquals(3, issueList.size());
|
||||
for (Iterator<IssueEntity> iterator = issueList.iterator(); iterator.hasNext(); ) {
|
||||
IssueEntity next = iterator.next();
|
||||
issueImpl.delete(next);
|
||||
}
|
||||
issueList = issueImpl.findAll();
|
||||
Assert.assertNotNull(issueList);
|
||||
Assert.assertEquals(0, issueList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.PublisherEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 20.01.2015.
|
||||
*/
|
||||
public class PublisherImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublisherAddAndDelete() {
|
||||
String publisherName = "testPublisherAddAndDelete";
|
||||
PublisherImpl publisherImpl = new PublisherImpl();
|
||||
PublisherEntity publisher = publisherImpl.addPublisher(publisherName);
|
||||
Collection<PublisherEntity> publisherList = publisherImpl.findByName(publisherName);
|
||||
Assert.assertEquals(1, publisherList.size());
|
||||
publisherImpl.delete(publisher);
|
||||
publisherList = publisherImpl.findByName(publisherName);
|
||||
Assert.assertEquals(0, publisherList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublisherFindAll() {
|
||||
PublisherImpl publisherImpl = new PublisherImpl();
|
||||
publisherImpl.addPublisher("testDeletePublisher1");
|
||||
publisherImpl.addPublisher("testDeletePublisher2");
|
||||
publisherImpl.addPublisher("testDeletePublisher3");
|
||||
Collection<PublisherEntity> publisherList = publisherImpl.findAll();
|
||||
Assert.assertEquals(3, publisherList.size());
|
||||
for (Iterator<PublisherEntity> iterator = publisherList.iterator(); iterator.hasNext(); ) {
|
||||
PublisherEntity next = iterator.next();
|
||||
publisherImpl.delete(next);
|
||||
}
|
||||
publisherList = publisherImpl.findAll();
|
||||
Assert.assertEquals(0, publisherList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.StoryArcEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class StoryArcImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoryArcAddAndDelete() {
|
||||
String storyArcTtitle = "testStoryArcAddAndDelete";
|
||||
StoryArcImpl storyArcImpl = new StoryArcImpl();
|
||||
StoryArcEntity storyArc = new StoryArcEntity();
|
||||
storyArc.setTitle(storyArcTtitle);
|
||||
storyArcImpl.store(storyArc);
|
||||
Collection<StoryArcEntity> storyArcEntityCollection = storyArcImpl.findByTitle(storyArcTtitle);
|
||||
Assert.assertNotNull(storyArcEntityCollection);
|
||||
Assert.assertEquals(1, storyArcEntityCollection.size());
|
||||
storyArcImpl.delete(storyArc);
|
||||
storyArcEntityCollection = storyArcImpl.findByTitle(storyArcTtitle);
|
||||
Assert.assertNotNull(storyArcEntityCollection);
|
||||
Assert.assertEquals(0, storyArcEntityCollection.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoryArcFindAll() {
|
||||
StoryArcImpl storyArcImpl = new StoryArcImpl();
|
||||
StoryArcEntity storyArc;
|
||||
storyArc = new StoryArcEntity();
|
||||
storyArc.setTitle("testStoryArcFindAll1");
|
||||
storyArcImpl.store(storyArc);
|
||||
storyArc = new StoryArcEntity();
|
||||
storyArc.setTitle("testStoryArcFindAll2");
|
||||
storyArcImpl.store(storyArc);
|
||||
storyArc = new StoryArcEntity();
|
||||
storyArc.setTitle("testStoryArcFindAll3");
|
||||
storyArcImpl.store(storyArc);
|
||||
Collection<StoryArcEntity> storyArcEntityCollection = storyArcImpl.findAll();
|
||||
Assert.assertNotNull(storyArcEntityCollection);
|
||||
Assert.assertEquals(3, storyArcEntityCollection.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.ibtp.kontor.comics.dal;
|
||||
|
||||
import com.ibtp.kontor.comics.entity.VolumeEntity;
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 28.01.2015.
|
||||
*/
|
||||
public class VolumeImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVolumeAddAndDelete() {
|
||||
String volumeTitle = "testVolumeAddAndDelete";
|
||||
VolumeImpl volumeImpl = new VolumeImpl();
|
||||
VolumeEntity volume = new VolumeEntity();
|
||||
volume.setTitle(volumeTitle);
|
||||
VolumeEntity volumeEntity = volumeImpl.store(volume);
|
||||
Assert.assertNotNull(volumeEntity);
|
||||
Assert.assertEquals(volumeTitle, volumeEntity.getTitle());
|
||||
Collection<VolumeEntity> volumeList = volumeImpl.findByTitle(volumeTitle);
|
||||
Assert.assertNotNull(volumeList);
|
||||
Assert.assertEquals(1, volumeList.size());
|
||||
VolumeEntity result = (VolumeEntity)volumeList.toArray()[0];
|
||||
Assert.assertEquals(volume, result);
|
||||
volumeImpl.delete(result);
|
||||
volumeList = volumeImpl.findByTitle(volumeTitle);
|
||||
Assert.assertEquals(0, volumeList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testVolumeFindAll() {
|
||||
VolumeImpl volumeImpl = new VolumeImpl();
|
||||
VolumeEntity volume;
|
||||
volume = new VolumeEntity();
|
||||
volume.setTitle("testVolumeFindAll1");
|
||||
volumeImpl.store(volume);
|
||||
volume = new VolumeEntity();
|
||||
volume.setTitle("testVolumeFindAll2");
|
||||
volumeImpl.store(volume);
|
||||
volume = new VolumeEntity();
|
||||
volume.setTitle("testVolumeFindAll3");
|
||||
volumeImpl.store(volume);
|
||||
Collection<VolumeEntity> volumeList = volumeImpl.findAll();
|
||||
Assert.assertNotNull(volumeList);
|
||||
Assert.assertEquals(3, volumeList.size());
|
||||
for (Iterator<VolumeEntity> iterator = volumeList.iterator(); iterator.hasNext(); ) {
|
||||
VolumeEntity next = iterator.next();
|
||||
volumeImpl.delete(next);
|
||||
}
|
||||
volumeList = volumeImpl.findAll();
|
||||
Assert.assertNotNull(volumeList);
|
||||
Assert.assertEquals(0, volumeList.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.ibtp.kontor.dal;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 10.02.2015.
|
||||
*/
|
||||
public class DataAccessLayerTest {
|
||||
|
||||
public void findTests(String packageName, String entityName) {
|
||||
String testClassName = packageName + entityName + "ImplTest";
|
||||
Class testClass;
|
||||
try {
|
||||
testClass = Class.forName(testClassName);
|
||||
Method addAndDelete = testClass.getMethod("test" + entityName + "AddAndDelete");
|
||||
Method findAll = testClass.getMethod("test" + entityName + "FindAll");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Assert.fail("Class " + testClassName + " missing");
|
||||
} catch (NoSuchMethodException e) {
|
||||
Assert.fail("Test method for class " + testClassName + " missing");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindComicTests() {
|
||||
/*
|
||||
* Find all Tests
|
||||
*/
|
||||
String[] testClasses = new String[]{"Artist", "Comic", "Issue", "Publisher", "StoryArc", "Volume"};
|
||||
for (int i = 0; i < testClasses.length; i++) {
|
||||
String testEntity = testClasses[i];
|
||||
findTests("com.ibtp.kontor.comics.dal.", testEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindLibraryTests() {
|
||||
/*
|
||||
* Find all Tests
|
||||
*/
|
||||
String[] testClasses = new String[]{"Article", "Author", "Book", "File", "Title"};
|
||||
for (int i = 0; i < testClasses.length; i++) {
|
||||
String testEntity = testClasses[i];
|
||||
findTests("com.ibtp.kontor.library.dal.", testEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindTradingCardsTests() {
|
||||
/*
|
||||
* Find all Tests
|
||||
*/
|
||||
String[] testClasses = new String[]{"BaseSet", "Insert", "Manufacturer", "ParallelSet", "Player", "Position", "SportCard", "Sport", "Team"};
|
||||
for (int i = 0; i < testClasses.length; i++) {
|
||||
String testEntity = testClasses[i];
|
||||
findTests("com.ibtp.kontor.tradingcards.dal." , testEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.ibtp.kontor.library;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class BookshelfTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAuthors() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.library.entity.ArticleEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 23.01.2015.
|
||||
*/
|
||||
public class ArticleImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddArticle() {
|
||||
String articleTitle = "testAddArticle";
|
||||
ArticleImpl articleImpl = new ArticleImpl();
|
||||
ArticleEntity article = articleImpl.addArticle(articleTitle);
|
||||
Assert.assertNotNull(article);
|
||||
List<ArticleEntity> articleList = articleImpl.findByTitle(articleTitle);
|
||||
Assert.assertEquals(1, articleList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArticleAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArticleFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.library.entity.AuthorEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by thomas on 23.01.15.
|
||||
*/
|
||||
public class AuthorImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAuthor() {
|
||||
String authorName = "testAddAuthor";
|
||||
AuthorImpl authorImpl = new AuthorImpl();
|
||||
AuthorEntity author = authorImpl.addAuthor(authorName);
|
||||
Assert.assertNotNull(author);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAuthor() {
|
||||
String authorName = "testDeleteAuthor";
|
||||
AuthorImpl authorImpl = new AuthorImpl();
|
||||
AuthorEntity author = authorImpl.addAuthor(authorName);
|
||||
Assert.assertNotNull(author);
|
||||
List<AuthorEntity> authorList = authorImpl.findByName(authorName);
|
||||
Assert.assertEquals(1, authorList.size());
|
||||
authorImpl.delete(author);
|
||||
authorList = authorImpl.findByName(authorName);
|
||||
Assert.assertEquals(0, authorList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthorAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAuthorFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class BookImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBookAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBookFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class FileImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.library.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class TitleImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTitleAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTitleFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package com.ibtp.kontor.tradingcards;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.tradingcards.dal.TeamImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.TeamEntity;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.tradingcards.dal.SportImpl;
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 27.01.2015.
|
||||
*/
|
||||
public class CollectionTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
setupSports();
|
||||
}
|
||||
|
||||
public void setupSports() {
|
||||
SportImpl sportImpl = new SportImpl();
|
||||
SportEntity football = sportImpl.addSport("Football");
|
||||
setupFootballTeams(football);
|
||||
SportEntity baseball = sportImpl.addSport("Baseball");
|
||||
setupFootballTeams(baseball);
|
||||
SportEntity basketball = sportImpl.addSport("Basketball");
|
||||
setupBasketballTeams(basketball);
|
||||
SportEntity hockey = sportImpl.addSport("Hockey");
|
||||
setupHockeyTeams(hockey);
|
||||
}
|
||||
|
||||
public void setupFootballTeams(SportEntity football) {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
teamImpl.addTeam("Dallas Cowboys", football);
|
||||
teamImpl.addTeam("New York Giants", football);
|
||||
teamImpl.addTeam("Philadelphia Eagles", football);
|
||||
teamImpl.addTeam("Arizona Cardinals", football);
|
||||
teamImpl.addTeam("Washington Redskins", football);
|
||||
teamImpl.addTeam("Detroit Lions", football);
|
||||
teamImpl.addTeam("Minnesota Vikings", football);
|
||||
teamImpl.addTeam("Green Bay Packers", football);
|
||||
teamImpl.addTeam("Chicago Bears", football);
|
||||
teamImpl.addTeam("Tampa Bay Buccaneers", football);
|
||||
teamImpl.addTeam("San Francisco 49ers", football);
|
||||
teamImpl.addTeam("New Orleans Saints", football);
|
||||
teamImpl.addTeam("Atlanta Falcons", football);
|
||||
teamImpl.addTeam("Los Angeles Rams", football);
|
||||
teamImpl.addTeam("Buffalo Bills", football);
|
||||
teamImpl.addTeam("Miami Dolphins", football);
|
||||
teamImpl.addTeam("New York Jets", football);
|
||||
teamImpl.addTeam("New England Patriots", football);
|
||||
teamImpl.addTeam("Indianapolis Colts", football);
|
||||
teamImpl.addTeam("Houston Oilers", football);
|
||||
teamImpl.addTeam("Pittsburgh Steelers", football);
|
||||
teamImpl.addTeam("Cleveland Browns", football);
|
||||
teamImpl.addTeam("Kansas City Chiefs", football);
|
||||
teamImpl.addTeam("Los Angeles Raiders", football);
|
||||
teamImpl.addTeam("Denver Broncos", football);
|
||||
teamImpl.addTeam("San Diego Chargers", football);
|
||||
teamImpl.addTeam("Seattle Seahawks", football);
|
||||
teamImpl.addTeam("Jacksonville Jaguars", football);
|
||||
teamImpl.addTeam("Houston Texans", football);
|
||||
}
|
||||
|
||||
public void setupBaseballTeams(SportEntity baseball) {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
}
|
||||
|
||||
public void setupBasketballTeams(SportEntity basketball) {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
teamImpl.addTeam("Houston Rockets", basketball);
|
||||
teamImpl.addTeam("San Antonio Spurs", basketball);
|
||||
teamImpl.addTeam("Utah Jazz", basketball);
|
||||
teamImpl.addTeam("Denver Nuggets", basketball);
|
||||
teamImpl.addTeam("Minnesota Timberwolves", basketball);
|
||||
teamImpl.addTeam("Dallas Mavericks", basketball);
|
||||
teamImpl.addTeam("Seattle SuperSonics", basketball);
|
||||
teamImpl.addTeam("Phoenix Suns", basketball);
|
||||
teamImpl.addTeam("Golden State Warriors", basketball);
|
||||
teamImpl.addTeam("Portland Trail Blazers", basketball);
|
||||
teamImpl.addTeam("Los Angeles Lakers", basketball);
|
||||
teamImpl.addTeam("Sacramento Kings", basketball);
|
||||
teamImpl.addTeam("Los Angeles Clippers", basketball);
|
||||
teamImpl.addTeam("New York Knicks", basketball);
|
||||
teamImpl.addTeam("Orlando Magic", basketball);
|
||||
teamImpl.addTeam("New Jersey Nets", basketball);
|
||||
teamImpl.addTeam("Miami Heat", basketball);
|
||||
teamImpl.addTeam("Boston Celtics", basketball);
|
||||
teamImpl.addTeam("Philadelphia 76ers", basketball);
|
||||
teamImpl.addTeam("Washington Bullets", basketball);
|
||||
teamImpl.addTeam("Atlanta Hawks", basketball);
|
||||
teamImpl.addTeam("Chicago Bulls", basketball);
|
||||
teamImpl.addTeam("Indiana Pacers", basketball);
|
||||
teamImpl.addTeam("Cleveland Cavaliers", basketball);
|
||||
teamImpl.addTeam("Charlotte Hornets", basketball);
|
||||
teamImpl.addTeam("Detroit Pistons", basketball);
|
||||
teamImpl.addTeam("Milwaukee Bucks", basketball);
|
||||
}
|
||||
|
||||
public void setupHockeyTeams(SportEntity hockey) {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
teamImpl.addTeam("New York Rangers", hockey);
|
||||
teamImpl.addTeam("Buffalo Sabers", hockey);
|
||||
teamImpl.addTeam("Detroit Red Wings", hockey);
|
||||
teamImpl.addTeam("Vancouver Canucks", hockey);
|
||||
teamImpl.addTeam("Mighty Ducks of Anaheim", hockey);
|
||||
teamImpl.addTeam("Calgary Flames", hockey);
|
||||
teamImpl.addTeam("Edmonton Oilers", hockey);
|
||||
teamImpl.addTeam("Los Angeles Kings", hockey);
|
||||
teamImpl.addTeam("San Jose Sharks", hockey);
|
||||
teamImpl.addTeam("Chicago Blackhawks", hockey);
|
||||
teamImpl.addTeam("Dallas Stars", hockey);
|
||||
teamImpl.addTeam("St. Louis Blues", hockey);
|
||||
teamImpl.addTeam("Toronto Maple Leafs", hockey);
|
||||
teamImpl.addTeam("Winnipeg Jets", hockey);
|
||||
teamImpl.addTeam("Boston Bruins", hockey);
|
||||
teamImpl.addTeam("Hartford Whalers", hockey);
|
||||
teamImpl.addTeam("Montreal Canadiers", hockey);
|
||||
teamImpl.addTeam("Ottawa Senators", hockey);
|
||||
teamImpl.addTeam("Pittsburgh Penguins", hockey);
|
||||
teamImpl.addTeam("Quebec Nordiques", hockey);
|
||||
teamImpl.addTeam("Florida Panthers", hockey);
|
||||
teamImpl.addTeam("New Jersey Devils", hockey);
|
||||
teamImpl.addTeam("New York Islanders", hockey);
|
||||
teamImpl.addTeam("Philadelphia Flyers", hockey);
|
||||
teamImpl.addTeam("Tamba Bay Lightning", hockey);
|
||||
teamImpl.addTeam("Washington Capitals", hockey);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
Collection<TeamEntity> teamEntities = teamImpl.findAll();
|
||||
for (Iterator<TeamEntity> iterator = teamEntities.iterator(); iterator.hasNext(); ) {
|
||||
TeamEntity next = iterator.next();
|
||||
teamImpl.delete(next);
|
||||
}
|
||||
SportImpl sportImpl = new SportImpl();
|
||||
Collection<SportEntity> sportEntities = sportImpl.findAll();
|
||||
for (Iterator<SportEntity> iterator = sportEntities.iterator(); iterator.hasNext(); ) {
|
||||
SportEntity next = iterator.next();
|
||||
sportImpl.delete(next);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void gettAllSports() {
|
||||
SportImpl sportImpl = new SportImpl();
|
||||
Collection<SportEntity> resultList = sportImpl.findAll();
|
||||
Assert.assertEquals(4, resultList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllTeams() {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
Collection<TeamEntity> resultList = teamImpl.findAll();
|
||||
Assert.assertEquals(111, resultList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class BaseSetImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaseSetAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBaseSetFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class InsertImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInsertAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.tradingcards.entity.ManufacturerEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 20.01.2015.
|
||||
*/
|
||||
public class ManufacturerImplTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addManufacturer() {
|
||||
String manufacturerName = "Manufacturer1";
|
||||
ManufacturerImpl manufacturerImpl = new ManufacturerImpl();
|
||||
ManufacturerEntity manufacturer = manufacturerImpl.addManufacturer(manufacturerName);
|
||||
Assert.assertNotNull(manufacturer);
|
||||
List<ManufacturerEntity> manufacturerList = manufacturerImpl.findByName(manufacturerName);
|
||||
Assert.assertTrue(manufacturerList.size() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteManufacturer() {
|
||||
String manufacturerName = "Manufacturer1";
|
||||
ManufacturerImpl manufacturerImpl = new ManufacturerImpl();
|
||||
List<ManufacturerEntity> manufacturerList = manufacturerImpl.findByName(manufacturerName);
|
||||
Assert.assertTrue(manufacturerList.size() > 0);
|
||||
manufacturerImpl.delete(manufacturerList.get(0));
|
||||
manufacturerList = manufacturerImpl.findByName(manufacturerName);
|
||||
Assert.assertEquals(0, manufacturerList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManufacturerAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManufacturerFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class ParallelSetImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParallelSetAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testParallelSetFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class PlayerImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlayerAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlayerFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.tradingcards.entity.PositionEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class PositionImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionAddAndDelete() {
|
||||
String positionName = "testPositionAddAndDelete";
|
||||
PositionImpl positionImpl = new PositionImpl();
|
||||
PositionEntity position = positionImpl.addPosition(positionName);
|
||||
Collection<PositionEntity> resultList = positionImpl.findByName(positionName);
|
||||
Assert.assertNotNull(resultList);
|
||||
Assert.assertEquals(1, resultList.size());
|
||||
positionImpl.delete(position);
|
||||
resultList = positionImpl.findByName(positionName);
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPositionFindAll() {
|
||||
PositionImpl positionImpl = new PositionImpl();
|
||||
Collection<PositionEntity> resultList = positionImpl.findAll();
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 27.01.2015.
|
||||
*/
|
||||
public class SportCardImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSportCardAddAndDelete() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSportCardFindAll() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.tradingcards.entity.SportEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 19.01.2015.
|
||||
*/
|
||||
public class SportImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSportAddAndDelete() {
|
||||
String sportName = "testSportAddAndDelete";
|
||||
SportImpl sportImpl = new SportImpl();
|
||||
SportEntity sport = sportImpl.addSport(sportName);
|
||||
List<SportEntity> sportList = sportImpl.findByName(sportName);
|
||||
Assert.assertEquals(1, sportList.size());
|
||||
sportImpl.delete(sport);
|
||||
List<SportEntity> result = sportImpl.findByName(sportName);
|
||||
Assert.assertEquals(0, result.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSportFindAll() {
|
||||
SportImpl sportImpl = new SportImpl();
|
||||
Collection<SportEntity> resultList = sportImpl.findAll();
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.ibtp.kontor.tradingcards.dal;
|
||||
|
||||
import com.ibtp.kontor.dal.DatabaseManager;
|
||||
import com.ibtp.kontor.util.LocalTestDatabase;
|
||||
import com.ibtp.kontor.tradingcards.entity.TeamEntity;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by tpeetz on 20.01.2015.
|
||||
*/
|
||||
public class TeamImplTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
DatabaseManager.setDatabase(new LocalTestDatabase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTeamAddAndDelete() {
|
||||
String teamName = "testTeamAddAndDelete";
|
||||
TeamEntity team = new TeamEntity(teamName);
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
teamImpl.store(team);
|
||||
Collection<TeamEntity> resultList = teamImpl.findByName(teamName);
|
||||
Assert.assertEquals(1, resultList.size());
|
||||
teamImpl.delete(team);
|
||||
resultList = teamImpl.findByName(teamName);
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTeamFindAll() {
|
||||
TeamImpl teamImpl = new TeamImpl();
|
||||
Collection<TeamEntity> resultList = teamImpl.findAll();
|
||||
Assert.assertEquals(0, resultList.size());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.ibtp.kontor.util;
|
||||
|
||||
import com.ibtp.kontor.dal.Database;
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.hsqldb.Server;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.persistence.Persistence;
|
||||
import javax.persistence.spi.PersistenceProvider;
|
||||
import javax.persistence.spi.PersistenceProviderResolver;
|
||||
import javax.persistence.spi.PersistenceProviderResolverHolder;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Created by TPEETZ on 21.01.2015.
|
||||
*/
|
||||
public class LocalTestDatabase implements Database {
|
||||
|
||||
private static Server server;
|
||||
private static EntityManagerFactory factory;
|
||||
private static EntityManager em;
|
||||
private static Logger logger = LoggerFactory.getLogger(LocalTestDatabase.class.getName());
|
||||
|
||||
static {
|
||||
logger.info("initialization and starting database");
|
||||
LocalTestDatabase.assureDatabaseRunning();
|
||||
}
|
||||
|
||||
public LocalTestDatabase() {
|
||||
logger.info("LocalDatabaseTest started");
|
||||
}
|
||||
|
||||
private static void assureDatabaseRunning() {
|
||||
if (LocalTestDatabase.server == null) {
|
||||
LocalTestDatabase.startDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
private static void startDatabase() {
|
||||
logger.info("startDatabase as kontor in hsqldb_databases/test");
|
||||
LocalTestDatabase.server = new Server();
|
||||
LocalTestDatabase.server.setAddress("localhost");
|
||||
LocalTestDatabase.server.setDatabaseName(0, "kontor");
|
||||
LocalTestDatabase.server.setDatabasePath(0, "file:build/hsqldb_databases/test");
|
||||
LocalTestDatabase.server.setPort(2345);
|
||||
LocalTestDatabase.server.setTrace(true);
|
||||
LocalTestDatabase.server.setLogWriter(new PrintWriter(System.out));
|
||||
LocalTestDatabase.server.start();
|
||||
}
|
||||
|
||||
private static void stopDatabase() {
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
private static EntityManagerFactory getFactory() {
|
||||
if (LocalTestDatabase.factory == null) {
|
||||
LocalTestDatabase.assureDatabaseRunning();
|
||||
PersistenceProviderResolverHolder.setPersistenceProviderResolver(new PersistenceProviderResolver() {
|
||||
private final List<PersistenceProvider> providers_ = Arrays.asList((PersistenceProvider) new HibernatePersistenceProvider());
|
||||
|
||||
@Override
|
||||
public void clearCachedProviders() {
|
||||
// Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PersistenceProvider> getPersistenceProviders() {
|
||||
return providers_;
|
||||
}
|
||||
});
|
||||
LocalTestDatabase.factory = Persistence.createEntityManagerFactory("com.ibtp.kontor");
|
||||
logger.info("EntityManagerFactory(com.ibtp.kontor) created");
|
||||
}
|
||||
return factory;
|
||||
}
|
||||
|
||||
private static EntityManager getSingleEntityManager() {
|
||||
return LocalTestDatabase.em;
|
||||
}
|
||||
|
||||
private static void setSingleEntityManager(EntityManager manager) {
|
||||
LocalTestDatabase.em = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityManager getEntityManager() {
|
||||
if (getSingleEntityManager() == null) {
|
||||
setSingleEntityManager(getFactory().createEntityManager());
|
||||
logger.info("EntityManager created");
|
||||
}
|
||||
return getSingleEntityManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String serverMessage;
|
||||
if (LocalTestDatabase.server == null) {
|
||||
serverMessage = "server:null";
|
||||
} else {
|
||||
serverMessage = LocalTestDatabase.server.toString();
|
||||
}
|
||||
return LocalTestDatabase.class.getName() + " " + serverMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
|
||||
version="2.0">
|
||||
<persistence-unit name="com.ibtp.kontor" >
|
||||
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
|
||||
<class>com.ibtp.kontor.comics.entity.ArtistEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.ComicEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.IssueEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.StoryArcEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.VolumeEntity</class>
|
||||
<class>com.ibtp.kontor.comics.entity.PublisherEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.AuthorEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.ArticleEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.BookEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.FileEntity</class>
|
||||
<class>com.ibtp.kontor.library.entity.TitleEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.SportEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.TeamEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.PositionEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.PlayerEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.ManufacturerEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.BaseSetEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.InsertEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.ParallelSetEntity</class>
|
||||
<class>com.ibtp.kontor.tradingcards.entity.SportCardEntity</class>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
|
||||
<property name="javax.persistence.jdbc.user" value="sa"/>
|
||||
<property name="javax.persistence.jdbc.password" value=""/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:hsql://localhost:2345/kontor;shutdown=true;hsqldb.write_delay=false"/>
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
|
||||
<property name="hibernate.show_sql" value="true"/>
|
||||
<property name="hibernate.max_fetch_depth" value="3"/>
|
||||
<property name="hibernate.hbm2ddl.auto" value="update"/>
|
||||
<property name="hsqldb.write_delay" value="false"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE"
|
||||
class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>build/kontortest.log</file>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<Pattern>%d{yyyy-MM-dd_HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</Pattern>
|
||||
</encoder>
|
||||
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<FileNamePattern>build/kontortest.%i.log.zip</FileNamePattern>
|
||||
<MinIndex>1</MinIndex>
|
||||
<MaxIndex>10</MaxIndex>
|
||||
</rollingPolicy>
|
||||
|
||||
<triggeringPolicy
|
||||
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>2MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
|
||||
</appender>
|
||||
|
||||
<logger name="org.hibernate.type" level="ALL" />
|
||||
<logger name="org.hibernate" level="DEBUG" />
|
||||
<logger name="com.ibtp" level="DEBUG" />
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user