import sources from develop/0.1.0

This commit is contained in:
Thomas Peetz
2025-04-29 12:52:55 +02:00
parent 304005822c
commit 4c96de27db
976 changed files with 58265 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
jar {
manifest {
attributes 'Implementation-Title': 'Comics', 'Implementation-Version': version
}
}
@@ -0,0 +1,192 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!--
Checkstyle configuration that checks the sun coding conventions from:
- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html
- the Sun Code Conventions at http://java.sun.com/docs/codeconv/
- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html
- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html
- some best practices
Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).
Most Checks are configurable, be sure to consult the documentation.
To completely disable a check, just comment it out or delete it from the file.
Finally, it is worth reading the documentation.
-->
<module name="Checker">
<!--
If you set the basedir property below, then all reported file
names will be relative to the specified directory. See
http://checkstyle.sourceforge.net/5.x/config.html#Checker
<property name="basedir" value="${basedir}"/>
-->
<!-- Checks that each Java package has a Javadoc file used for commenting. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<module name="JavadocPackage">
<property name="allowLegacy" value="true"/>
</module>
<!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"/>
<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<module name="FileLength"/>
<!-- Following interprets the header file as regular expressions. -->
<!-- <module name="RegexpHeader"/> -->
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<module name="TreeWalker">
<!--<property name="cacheFile" value="${checkstyle.cache.file}"/>-->
<property name="cacheFile" value="build/checkstyle-cachefile"/>
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocMethod"/>
<module name="JavadocType"/>
<module name="JavadocVariable"/>
<module name="JavadocStyle"/>
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for Headers -->
<!-- See http://checkstyle.sf.net/config_header.html -->
<!-- <module name="Header"> -->
<!-- The follow property value demonstrates the ability -->
<!-- to have access to ANT properties. In this case it uses -->
<!-- the ${basedir} property to allow Checkstyle to be run -->
<!-- from any directory within a project. See property -->
<!-- expansion, -->
<!-- http://checkstyle.sf.net/config.html#properties -->
<!-- <property -->
<!-- name="headerFile" -->
<!-- value="${basedir}/java.header"/> -->
<!-- </module> -->
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidInlineConditionals"/>
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true"/>
<property name="ignoreSetter" value="true"/>
</module>
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<module name="MagicNumber"/>
<module name="MissingSwitchDefault"/>
<module name="RedundantThrows"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<module name="DesignForExtension"/>
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="FinalParameters"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module>
</module>
@@ -0,0 +1,179 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />
<!-- Checkstyle XML Style Sheet by Stephane Bailliez <sbailliez@apache.org> -->
<!-- Part of the Checkstyle distribution found at http://checkstyle.sourceforge.net -->
<!-- Usage (generates checkstyle_report.html): -->
<!-- <checkstyle failonviolation="false" config="${check.config}"> -->
<!-- <fileset dir="${src.dir}" includes="**/*.java"/> -->
<!-- <formatter type="xml" toFile="${doc.dir}/checkstyle_report.xml"/> -->
<!-- </checkstyle> -->
<!-- <style basedir="${doc.dir}" destdir="${doc.dir}" -->
<!-- includes="checkstyle_report.xml" -->
<!-- style="${doc.dir}/checkstyle-noframes.xsl"/> -->
<xsl:template match="checkstyle">
<html>
<head>
<style type="text/css">
.bannercell {
border: 0px;
padding: 0px;
}
body {
margin-left: 10;
margin-right: 10;
font:normal 80% arial,helvetica,sanserif;
background-color:#FFFFFF;
color:#000000;
}
.a td {
background: #efefef;
}
.b td {
background: #fff;
}
th, td {
text-align: left;
vertical-align: top;
}
th {
font-weight:bold;
background: #ccc;
color: black;
}
table, th, td {
font-size:100%;
border: none
}
table.log tr td, tr th {
}
h2 {
font-weight:bold;
font-size:140%;
margin-bottom: 5;
}
h3 {
font-size:100%;
font-weight:bold;
background: #525D76;
color: white;
text-decoration: none;
padding: 5px;
margin-right: 2px;
margin-left: 2px;
margin-bottom: 0;
}
</style>
</head>
<body>
<a name="top"></a>
<!-- jakarta logo -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td class="bannercell" rowspan="2">
<!--a href="http://jakarta.apache.org/">
<img src="http://jakarta.apache.org/images/jakarta-logo.gif" alt="http://jakarta.apache.org" align="left" border="0"/>
</a-->
</td>
<td class="text-align:right"><h2>CheckStyle Audit</h2></td>
</tr>
<tr>
<td class="text-align:right">Designed for use with <a href='http://checkstyle.sourceforge.net/'>CheckStyle</a> and <a href='http://jakarta.apache.org'>Ant</a>.</td>
</tr>
</table>
<hr size="1"/>
<!-- Summary part -->
<xsl:apply-templates select="." mode="summary"/>
<hr size="1" width="100%" align="left"/>
<!-- Package List part -->
<xsl:apply-templates select="." mode="filelist"/>
<hr size="1" width="100%" align="left"/>
<!-- For each package create its part -->
<xsl:for-each select="file">
<xsl:sort select="@name"/>
<xsl:apply-templates select="."/>
<p/>
<p/>
</xsl:for-each>
<hr size="1" width="100%" align="left"/>
</body>
</html>
</xsl:template>
<xsl:template match="checkstyle" mode="filelist">
<h3>Files</h3>
<table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
<tr>
<th>Name</th>
<th>Errors</th>
</tr>
<xsl:for-each select="file">
<xsl:sort select="@name"/>
<xsl:variable name="errorCount" select="count(error)"/>
<tr>
<xsl:call-template name="alternated-row"/>
<td><a href="#f-{@name}"><xsl:value-of select="@name"/></a></td>
<td><xsl:value-of select="$errorCount"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="file">
<a name="f-{@name}"></a>
<h3>File <xsl:value-of select="@name"/></h3>
<table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
<tr>
<th>Error Description</th>
<th>Line</th>
</tr>
<xsl:for-each select="error">
<tr>
<xsl:call-template name="alternated-row"/>
<td><xsl:value-of select="@message"/></td>
<td><xsl:value-of select="@line"/></td>
</tr>
</xsl:for-each>
</table>
<a href="#top">Back to top</a>
</xsl:template>
<xsl:template match="checkstyle" mode="summary">
<h3>Summary</h3>
<xsl:variable name="fileCount" select="count(file)"/>
<xsl:variable name="errorCount" select="count(file/error)"/>
<table class="log" border="0" cellpadding="5" cellspacing="2" width="100%">
<tr>
<th>Files</th>
<th>Errors</th>
</tr>
<tr>
<xsl:call-template name="alternated-row"/>
<td><xsl:value-of select="$fileCount"/></td>
<td><xsl:value-of select="$errorCount"/></td>
</tr>
</table>
</xsl:template>
<xsl:template name="alternated-row">
<xsl:attribute name="class">
<xsl:if test="position() mod 2 = 1">a</xsl:if>
<xsl:if test="position() mod 2 = 0">b</xsl:if>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
@@ -0,0 +1,15 @@
<FindBugsFilter>
<Match>
<Bug category="PERFORMANCE" />
</Match>
<!-- All bugs in test classes, except for JUnit-specific bugs -->
<Match>
<Class name="~.*\.*Test" />
<Not>
<Bug code="IJU" />
</Not>
</Match>
</FindBugsFilter>
@@ -0,0 +1,19 @@
package com.peetz.comics.dal;
import java.util.List;
import javax.ejb.Local;
import com.peetz.comics.entity.ArtistEntity;
@Local
public interface ArtistDao {
public ArtistEntity getById(Long id);
public List<ArtistEntity> findByIds(List<Long> ids);
public ArtistEntity store(ArtistEntity entity);
public void delete(ArtistEntity entity);
}
@@ -0,0 +1,45 @@
package com.peetz.comics.dal;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.peetz.comics.entity.ArtistEntity;
@Stateless(name = "ArtistDao")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ArtistImpl implements ArtistDao {
@PersistenceContext(unitName = "kontor")
private EntityManager em;
@Override
public ArtistEntity getById(Long id) {
Query q = em.createNamedQuery("");
q.setParameter("id", id);
ArtistEntity entity = (ArtistEntity)q.getSingleResult();
return entity;
}
@Override
public List<ArtistEntity> findByIds(List<Long> ids) {
// TODO Auto-generated method stub
return null;
}
@Override
public ArtistEntity store(ArtistEntity entity) {
em.persist(entity);
return entity;
}
@Override
public void delete(ArtistEntity entity) {
em.remove(entity);
}
}
@@ -0,0 +1,23 @@
package com.peetz.comics.dal;
import java.util.List;
import javax.ejb.Local;
import com.peetz.comics.entity.ComicEntity;
import com.peetz.comics.entity.PublisherEntity;
@Local
public interface ComicDao {
public ComicEntity getById(Long id);
public List<ComicEntity> findByIds(List<Long> ids);
public List<ComicEntity> findByTitle(String title);
public ComicEntity assignPublisher(ComicEntity comic, PublisherEntity publisher);
public ComicEntity store(ComicEntity entity);
public void delete(ComicEntity entity);
}
@@ -0,0 +1,62 @@
package com.peetz.comics.dal;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.peetz.comics.entity.ComicEntity;
import com.peetz.comics.entity.PublisherEntity;
@Stateless(name = "ComicDao")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ComicImpl implements ComicDao {
@PersistenceContext(unitName = "kontor")
private EntityManager em;
@Override
public ComicEntity getById(Long id) {
Query q = em.createNamedQuery("Comic.findById");
q.setParameter("id", id);
ComicEntity entity = (ComicEntity)q.getSingleResult();
return entity;
}
@Override
public List<ComicEntity> findByIds(List<Long> ids) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<ComicEntity> findByTitle(String title) {
Query q = em.createNamedQuery("Comic.findByTitle");
q.setParameter("title", title);
@SuppressWarnings("unchecked")
List<ComicEntity> resultList = q.getResultList();
return resultList;
}
@Override
public ComicEntity assignPublisher(ComicEntity comic,
PublisherEntity publisher) {
// TODO Auto-generated method stub
return null;
}
@Override
public ComicEntity store(ComicEntity entity) {
em.persist(entity);
return entity;
}
@Override
public void delete(ComicEntity entity) {
em.remove(entity);
}
}
@@ -0,0 +1,69 @@
package com.peetz.comics.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="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>();
@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; }
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;
}
}
@@ -0,0 +1,90 @@
package com.peetz.comics.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="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>();
public 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,80 @@
package com.peetz.comics.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="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,48 @@
package com.peetz.comics.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="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>();
@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; }
public void setComic(Collection<ComicEntity> comic) { this.comic = comic; }
@OneToMany(mappedBy="publisher", cascade=CascadeType.REMOVE)
public Collection<ComicEntity> getComic() { return comic; }
}
@@ -0,0 +1,56 @@
package com.peetz.comics.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="StoryArc.findAll", query="SELECT a from StoryArcEntity as a"),
@NamedQuery(name="StoryArc.findByArtist", query="SELECT a from StoryArcEntity as a WHERE a.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,37 @@
package com.peetz.comics.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="VOLUME")
public class VolumeEntity {
private Long id;
private String title;
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,34 @@
package com.peetz.comics.service;
import java.util.Collection;
import javax.ejb.Local;
import com.peetz.comics.entity.ArtistEntity;
import com.peetz.comics.entity.ComicEntity;
import com.peetz.comics.entity.IssueEntity;
import com.peetz.comics.entity.PublisherEntity;
import com.peetz.comics.entity.StoryArcEntity;
@Local
public interface ComicService {
public Collection<ComicEntity> getAllComics();
public Collection<PublisherEntity> getAllPublisher();
public Collection<ArtistEntity> getAllArtists();
public Collection<IssueEntity> getAllIssuesForComic(ComicEntity comic);
public Collection<StoryArcEntity> getAllStoryArcs();
public void addStoryArc(String title);
public void addPublisher(String name);
public ComicEntity addComic(String title);
public PublisherEntity getPublisherById(String nodeValue);
public void assignPublisher(ComicEntity comic, PublisherEntity publisher);
}
@@ -0,0 +1,92 @@
package com.peetz.comics.service;
import java.util.Collection;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import com.peetz.comics.entity.ArtistEntity;
import com.peetz.comics.entity.ComicEntity;
import com.peetz.comics.entity.IssueEntity;
import com.peetz.comics.entity.PublisherEntity;
import com.peetz.comics.entity.StoryArcEntity;
import java.util.ArrayList;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
@Stateless(name="ComicService")
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ComicServiceImpl implements ComicService {
@PersistenceContext(unitName = "kontor")
private EntityManager em;
@SuppressWarnings("unchecked")
@Override
public Collection<ComicEntity> getAllComics() {
Query query = em.createNamedQuery("Comic.findAll");
ArrayList<ComicEntity> comicList = new ArrayList<ComicEntity>(query.getResultList());
return comicList;
}
@Override
public Collection<PublisherEntity> getAllPublisher() {
Query query = em.createNamedQuery("Publisher.findAll");
@SuppressWarnings("unchecked")
ArrayList<PublisherEntity> publisherList = new ArrayList<PublisherEntity>(query.getResultList());
return publisherList;
}
@SuppressWarnings("unchecked")
@Override
public Collection<ArtistEntity> getAllArtists() {
Query query = em.createNamedQuery("Artist.findAll");
ArrayList<ArtistEntity> artistList = new ArrayList<ArtistEntity>(query.getResultList());
return artistList;
}
@Override
public Collection<IssueEntity> getAllIssuesForComic(ComicEntity comic) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<StoryArcEntity> getAllStoryArcs() {
// TODO Auto-generated method stub
return null;
}
@Override
public void addStoryArc(String title) {
// TODO Auto-generated method stub
}
@Override
public void addPublisher(String name) {
// TODO Auto-generated method stub
}
@Override
public ComicEntity addComic(String title) {
// TODO Auto-generated method stub
return null;
}
@Override
public PublisherEntity getPublisherById(String nodeValue) {
// TODO Auto-generated method stub
return null;
}
@Override
public void assignPublisher(ComicEntity comic, PublisherEntity publisher) {
// TODO Auto-generated method stub
}
}
@@ -0,0 +1,8 @@
/**
*
*/
/**
* @author TPEETZ
*
*/
package com.peetz.comics.service;
@@ -0,0 +1,195 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.peetz.comics.service;
import com.peetz.comics.entity.ArtistEntity;
import com.peetz.comics.entity.ComicEntity;
import com.peetz.comics.entity.IssueEntity;
import com.peetz.comics.entity.PublisherEntity;
import com.peetz.comics.entity.StoryArcEntity;
import java.util.Collection;
import javax.ejb.embeddable.EJBContainer;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Ignore;
/**
*
* @author TPEETZ
*/
public class ComicServiceImplTest {
private static ComicService instance;
private static EJBContainer container;
public ComicServiceImplTest() {
}
@BeforeClass
public static void setUpClass() throws Exception {
container = javax.ejb.embeddable.EJBContainer.createEJBContainer();
instance = (ComicService)container.getContext().lookup("java:global/main/ComicService");
}
@AfterClass
public static void tearDownClass() {
container.close();
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getAllComics method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetAllComics() throws Exception {
System.out.println("getAllComics");
Collection<ComicEntity> expResult = null;
Collection<ComicEntity> result = instance.getAllComics();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getAllPublisher method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetAllPublisher() throws Exception {
System.out.println("getAllPublisher");
Collection<PublisherEntity> expResult = null;
Collection<PublisherEntity> result = instance.getAllPublisher();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getAllArtists method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetAllArtists() throws Exception {
System.out.println("getAllArtists");
Collection<ArtistEntity> expResult = null;
Collection<ArtistEntity> result = instance.getAllArtists();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getAllIssuesForComic method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetAllIssuesForComic() throws Exception {
System.out.println("getAllIssuesForComic");
ComicEntity comic = null;
Collection<IssueEntity> expResult = null;
Collection<IssueEntity> result = instance.getAllIssuesForComic(comic);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getAllStoryArcs method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetAllStoryArcs() throws Exception {
System.out.println("getAllStoryArcs");
Collection<StoryArcEntity> expResult = null;
Collection<StoryArcEntity> result = instance.getAllStoryArcs();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of addStoryArc method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testAddStoryArc() throws Exception {
System.out.println("addStoryArc");
String title = "";
instance.addStoryArc(title);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of addPublisher method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testAddPublisher() throws Exception {
System.out.println("addPublisher");
String name = "";
instance.addPublisher(name);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of addComic method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testAddComic() throws Exception {
System.out.println("addComic");
String title = "";
ComicEntity expResult = null;
ComicEntity result = instance.addComic(title);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getPublisherById method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testGetPublisherById() throws Exception {
System.out.println("getPublisherById");
String nodeValue = "";
PublisherEntity expResult = null;
PublisherEntity result = instance.getPublisherById(nodeValue);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of assignPublisher method, of class ComicServiceImpl.
*/
@Ignore
@Test
public void testAssignPublisher() throws Exception {
System.out.println("assignPublisher");
ComicEntity comic = null;
PublisherEntity publisher = null;
instance.assignPublisher(comic, publisher);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
}