Skip to content

Commit

Permalink
Merge branch 'master' into front-end-master
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroteles committed Nov 20, 2015
2 parents 2afca56 + aef7705 commit 239a857
Show file tree
Hide file tree
Showing 150 changed files with 1,682 additions and 33 deletions.
9 changes: 5 additions & 4 deletions Code-DD-UFG/Back-End/sdd-ufg/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<classpathentry kind="src" path="src/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
Expand Down
11 changes: 11 additions & 0 deletions Code-DD-UFG/Back-End/sdd-ufg/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
Expand All @@ -19,5 +29,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
org.eclipse.jpt.core.platform=eclipselink2_2
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<root>
<facet id="jpt.jpa">
<node name="libprov">
<attribute name="provider-id" value="jpa-no-op-library-provider"/>
</node>
</facet>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.5"/>
<installed facet="jpt.jpa" version="2.0"/>
</faceted-project>
12 changes: 5 additions & 7 deletions Code-DD-UFG/Back-End/sdd-ufg/params.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
server:
applicationConnectors:
- type: http
port: 8090
adminConnectors:
- type: http
port: 8091
database:
driverClass: org.postgresql.Driver
user: postgres
password: postgres
url: jdbc:postgresql://localhost/sddufg
82 changes: 78 additions & 4 deletions Code-DD-UFG/Back-End/sdd-ufg/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,88 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<dropwizard.version>0.8.4</dropwizard.version>
<dropwizard.version>0.6.2</dropwizard.version>
<dropwizardhibernate.version>0.8.4</dropwizardhibernate.version>
<guice.version>3.0</guice.version>
<hibernate.version>4.2.20.Final</hibernate.version>
</properties>

<dependencies>
<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
<groupId>com.yammer.dropwizard</groupId>
<artifactId>dropwizard-core</artifactId>
<version>${dropwizard.version}</version>
</dependency>

<dependency>
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-hibernate</artifactId>
<version>${dropwizardhibernate.version}</version>
</dependency>


<!-- Hibernate dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate.version}</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.1.Final</version>
</dependency>


<!-- JDBC dependencies -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>

<!-- Other dependences -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>jsr250-api</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-persist</artifactId>
<version>${guice.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.6</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-hibernate</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,33 +1,68 @@
package br.ufg.inf.sdd_ufg;

import io.dropwizard.Application;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import br.ufg.inf.sdd_ufg.config.JpaConfiguration;
import br.ufg.inf.sdd_ufg.dao.ClazzDao;
import br.ufg.inf.sdd_ufg.dao.ClazzIntentDao;
import br.ufg.inf.sdd_ufg.dao.CourseDao;
import br.ufg.inf.sdd_ufg.dao.DistributionProcessDao;
import br.ufg.inf.sdd_ufg.dao.GradeDao;
import br.ufg.inf.sdd_ufg.dao.KnowledgeGroupDao;
import br.ufg.inf.sdd_ufg.dao.TeacherDao;
import br.ufg.inf.sdd_ufg.dao.UserDao;
import br.ufg.inf.sdd_ufg.jpa.ClazzDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.ClazzIntentDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.CourseDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.DistributionProcessDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.GradeDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.KnowledgeGroupDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.TeacherDaoJpa;
import br.ufg.inf.sdd_ufg.jpa.UserDaoJpa;
import br.ufg.inf.sdd_ufg.resource.CourseResource;
import br.ufg.inf.sdd_ufg.resource.UserResource;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.persist.PersistFilter;
import com.yammer.dropwizard.Service;
import com.yammer.dropwizard.config.Bootstrap;
import com.yammer.dropwizard.config.Environment;

public class SddUfgApplication extends Application<SddUfgConfiguration> {

public class SddUfgApplication extends Service<SddUfgConfiguration> {
public static void main(String[] args) throws Exception {
new SddUfgApplication().run(args);
}

@Override
public String getName() {
return "sdd-ufg";
public void initialize(final Bootstrap<SddUfgConfiguration> bootstrap) {
bootstrap.setName("mr-api");
}

@Override
public void initialize(Bootstrap<SddUfgConfiguration> bootstrap) {
// nothing to do yet

private Injector createInjector(final SddUfgConfiguration conf) {
return Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(ClazzDao.class).to(ClazzDaoJpa.class);
bind(ClazzIntentDao.class).to(ClazzIntentDaoJpa.class);
bind(CourseDao.class).to(CourseDaoJpa.class);
bind(DistributionProcessDao.class).to(DistributionProcessDaoJpa.class);
bind(GradeDao.class).to(GradeDaoJpa.class);
bind(KnowledgeGroupDao.class).to(KnowledgeGroupDaoJpa.class);
bind(TeacherDao.class).to(TeacherDaoJpa.class);
bind(UserDao.class).to(UserDaoJpa.class);
}
}, JpaConfiguration.createJpaPersistModule(conf));
}


@Override
public void run(SddUfgConfiguration configuration, Environment environment) {
// Configure pretty print of json
ObjectMapper factory = environment.getObjectMapper();
factory.enable(SerializationFeature.INDENT_OUTPUT);
Injector injector = createInjector(configuration);

environment.addFilter(injector.getInstance(PersistFilter.class), "/*");
environment.addResource(injector.getInstance(UserResource.class));
environment.addResource(injector.getInstance(CourseResource.class));
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
package br.ufg.inf.sdd_ufg;

import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;

import com.yammer.dropwizard.config.Configuration;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonProperty;

public class SddUfgConfiguration extends Configuration {

}

@Valid
@NotNull
private DataSourceFactory database = new DataSourceFactory();

@JsonProperty("database")
public DataSourceFactory getDataSourceFactory() {
return database;
}

@JsonProperty("database")
public void setDataSourceFactory(DataSourceFactory dataSourceFactory) {
this.database = dataSourceFactory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package br.ufg.inf.sdd_ufg.config;

import java.util.Properties;

import br.ufg.inf.sdd_ufg.SddUfgConfiguration;

import com.google.inject.persist.jpa.JpaPersistModule;

public class JpaConfiguration {

public static JpaPersistModule createJpaPersistModule(SddUfgConfiguration conf) {
Properties props = new Properties();
props.put("javax.persistence.jdbc.url", conf.getDataSourceFactory().getUrl());
props.put("javax.persistence.jdbc.user", conf.getDataSourceFactory().getUser());
props.put("javax.persistence.jdbc.password", conf.getDataSourceFactory().getPassword());
props.put("javax.persistence.jdbc.driver", conf.getDataSourceFactory().getDriverClass());
JpaPersistModule jpaModule = new JpaPersistModule("Default");
jpaModule.properties(props);
return jpaModule;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.Clazz;

public interface ClazzDao extends EntityDao<Clazz> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.ClazzIntent;

public interface ClazzIntentDao extends EntityDao<ClazzIntent> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.Course;

public interface CourseDao extends EntityDao<Course> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.DistributionProcess;

public interface DistributionProcessDao extends EntityDao<DistributionProcess> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package br.ufg.inf.sdd_ufg.dao;

import java.util.List;

import br.ufg.inf.sdd_ufg.model.Entity;

public interface EntityDao <E extends Entity<E>> {

E create();

E findById(Long id, Integer depth);

List<E> findAll(Integer depth);

E refresh(E entity);

E save(E entity);

E insert(E entity);

E update(E entity);

void delete(E entity);
void delete(Long id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.Grade;

public interface GradeDao extends EntityDao<Grade> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.ufg.inf.sdd_ufg.dao;

import br.ufg.inf.sdd_ufg.model.KnowledgeGroup;

public interface KnowledgeGroupDao extends EntityDao<KnowledgeGroup> {
}
Loading

0 comments on commit 239a857

Please sign in to comment.