Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sachith_task/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Here I have commit that android mobile task and RESTful api which was developed, little time ago. That has use of Jersey framework and hibernate.

In the mobile applicaion I used a jersey client as the rest client. No deletion operation has developed. I used Android file management api for data store management.
115 changes: 115 additions & 0 deletions sachith_task/RESTSource/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.blackhat</groupId>
<artifactId>Blackhat</artifactId>
<version>2.0-SNAPSHOT</version>
<packaging>war</packaging>

<name>Blackhat</name>

<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.22.1</version>
<scope>provided</scope>
</dependency>
<!-- if you are using Jersey client specific features without the server side -->
<!--<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.22.1</version>
<scope>provided</scope>
</dependency>-->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>unknown-jars-temp-repo</id>
<name>A temporary repository created by NetBeans for libraries and jars it could not identify. Please replace the dependencies in this repository with correct ones and delete this repository.</name>
<url>file:${project.basedir}/lib</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.blackhat;

import javax.servlet.ServletContext;
import org.hibernate.Session;
import org.hibernate.SessionFactory;

/**
*
* @author Sachith Dickwella
*/
public abstract class BlackhatConstants {

public static String SESSION_FACTORY = "SessionFactory";

public static final Session getSession(ServletContext sc) {
return ((SessionFactory) sc.getAttribute(SESSION_FACTORY)).openSession();
}
}
218 changes: 218 additions & 0 deletions sachith_task/RESTSource/src/main/java/com/blackhat/entity/Artwork.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package com.blackhat.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

/**
*
* @author Sachith Dickwella
*/
@NamedQueries({
@NamedQuery(name = "getAllArtworks", query = "from Artwork a"),
@NamedQuery(name = "getArtworkById", query = "from Artwork a where a.id = :id")})
@Entity
@Table(name = "Artwork", uniqueConstraints = {
@UniqueConstraint(columnNames = {"ID"}),
@UniqueConstraint(columnNames = "REFERENCE_NO")})
public class Artwork implements Serializable {

private static final long serialVersionUID = -2208323497507122994L;

@Id
@NotNull
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID")
private int id;

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "JOB_ID", referencedColumnName = "ID")
private SampleJob jobId;

@NotNull
@Column(name = "REFERENCE_NO", length = 30)
private String referenceNumber;

@NotNull
@Column(name = "STATUS")
private char status;

@NotNull
@Column(name = "CREATE_USER", length = 30)
private String createUser;

@NotNull
@Temporal(TemporalType.DATE)
@Column(name = "CREATE_DATETIME")
private Date createDateTime;

@NotNull
@Column(name = "LASTUPDATE_USER", length = 30)
private String lastUpdateUser;

@NotNull
@Temporal(TemporalType.DATE)
@Column(name = "LASTUPDATE_DATETIME")
private Date lastUpdateDateTime;

@Column(name = "QC_USER", length = 30)
private String qcUser;

@Temporal(TemporalType.DATE)
@Column(name = "QC_DATETIME")
private Date qcDateTime;

/**
* @return the id
*/
public int getId() {
return id;
}

/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}

/**
* @return the jobId
*/
public SampleJob getJobId() {
return jobId;
}

/**
* @param jobId the jobId to set
*/
public void setJobId(SampleJob jobId) {
this.jobId = jobId;
}

/**
* @return the referenceNumber
*/
public String getReferenceNumber() {
return referenceNumber;
}

/**
* @param referenceNumber the referenceNumber to set
*/
public void setReferenceNumber(String referenceNumber) {
this.referenceNumber = referenceNumber;
}

/**
* @return the status
*/
public char getStatus() {
return status;
}

/**
* @param status the status to set
*/
public void setStatus(char status) {
this.status = status;
}

/**
* @return the createUser
*/
public String getCreateUser() {
return createUser;
}

/**
* @param createUser the createUser to set
*/
public void setCreateUser(String createUser) {
this.createUser = createUser;
}

/**
* @return the createDateTime
*/
public Date getCreateDateTime() {
return createDateTime;
}

/**
* @param createDateTime the createDateTime to set
*/
public void setCreateDateTime(Date createDateTime) {
this.createDateTime = createDateTime;
}

/**
* @return the lastUpdateUser
*/
public String getLastUpdateUser() {
return lastUpdateUser;
}

/**
* @param lastUpdateUser the lastUpdateUser to set
*/
public void setLastUpdateUser(String lastUpdateUser) {
this.lastUpdateUser = lastUpdateUser;
}

/**
* @return the lastUpdateDateTime
*/
public Date getLastUpdateDateTime() {
return lastUpdateDateTime;
}

/**
* @param lastUpdateDateTime the lastUpdateDateTime to set
*/
public void setLastUpdateDateTime(Date lastUpdateDateTime) {
this.lastUpdateDateTime = lastUpdateDateTime;
}

/**
* @return the qcUser
*/
public String getQcUser() {
return qcUser;
}

/**
* @param qcUser the qcUser to set
*/
public void setQcUser(String qcUser) {
this.qcUser = qcUser;
}

/**
* @return the qcDateTime
*/
public Date getQcDateTime() {
return qcDateTime;
}

/**
* @param qcDateTime the qcDateTime to set
*/
public void setQcDateTime(Date qcDateTime) {
this.qcDateTime = qcDateTime;
}
}
Loading