diff --git a/application.properties b/application.properties new file mode 100644 index 0000000..f5b0673 --- /dev/null +++ b/application.properties @@ -0,0 +1,13 @@ + +joinfaces.jsf.project-stage=development +joinfaces.primefaces.theme=omega + +spring.thymeleaf.enabled=false + +spring.datasource.url=jdbc:sqlite:/home/timh/foo/bazz/recipes.db +#spring.datasource.username=dbuser +#pring.datasource.password=dbpass +spring.datasource.driverClassName=org.sqlite.JDBC +#spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect +spring.jpa.database-platform=org.sqlite.hibernate.dialect.SQLiteDialect +#spring.jpa.show-sql: true \ No newline at end of file diff --git a/src/main/java/com/mousetech/gourmetj/CategoryRepository.java b/src/main/java/com/mousetech/gourmetj/CategoryRepository.java new file mode 100644 index 0000000..6ff92e0 --- /dev/null +++ b/src/main/java/com/mousetech/gourmetj/CategoryRepository.java @@ -0,0 +1,10 @@ +package com.mousetech.gourmetj; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.mousetech.gourmetj.persistence.model.Category; + +@Repository +public interface CategoryRepository extends JpaRepository { +} diff --git a/src/main/java/com/mousetech/gourmetj/CategoryService.java b/src/main/java/com/mousetech/gourmetj/CategoryService.java new file mode 100644 index 0000000..ada856d --- /dev/null +++ b/src/main/java/com/mousetech/gourmetj/CategoryService.java @@ -0,0 +1,24 @@ +package com.mousetech.gourmetj; + +import java.io.Serializable; +import java.util.List; +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import com.mousetech.gourmetj.persistence.model.Category; + +@Named +@ApplicationScoped +public class CategoryService implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + private CategoryRepository categoryRepository; + + + public List findAll() { + return categoryRepository.findAll(); + } +} diff --git a/src/main/java/com/mousetech/gourmetj/CategoryView.java b/src/main/java/com/mousetech/gourmetj/CategoryView.java new file mode 100644 index 0000000..8609d8f --- /dev/null +++ b/src/main/java/com/mousetech/gourmetj/CategoryView.java @@ -0,0 +1,31 @@ +package com.mousetech.gourmetj; + +import java.io.Serializable; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.faces.view.ViewScoped; +import javax.inject.Inject; +import javax.inject.Named; + +import com.mousetech.gourmetj.persistence.model.Category; + +@Named +@ViewScoped +public class CategoryView implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + private CategoryService categoryRepository; + + private List categories; + + @PostConstruct + public void init() { + categories = categoryRepository.findAll(); + } + + public List getCategories() { + return categories; + } +} diff --git a/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java b/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java new file mode 100644 index 0000000..1b640ce --- /dev/null +++ b/src/main/java/com/mousetech/gourmetj/SpringPrimeFacesApplication.java @@ -0,0 +1,15 @@ +package com.mousetech.gourmetj; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@EntityScan(value = {"com.mousetech.gourmetj.persistence.model", "com.codenotfound.primefaces"}) +public class SpringPrimeFacesApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringPrimeFacesApplication.class, args); + } +} diff --git a/src/main/java/com/mousetech/gourmetj/persistence/model/Category.java b/src/main/java/com/mousetech/gourmetj/persistence/model/Category.java new file mode 100644 index 0000000..0f30766 --- /dev/null +++ b/src/main/java/com/mousetech/gourmetj/persistence/model/Category.java @@ -0,0 +1,68 @@ +package com.mousetech.gourmetj.persistence.model; + +import java.io.Serializable; +import javax.persistence.*; + + +/** + * The persistent class for the "categories" database table. + * Generally only one category gets assigned per recipe, but the + * schema allows for more. There is no master category name + * table. + */ +@Entity +@Table(name="categories") +@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c") +public class Category implements Serializable { + private static final long serialVersionUID = 1L; + + @Column(name="category") + private String category; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name="id") + private Long id; + +// @ManyToOne(fetch=FetchType.EAGER, optional = false) +// @JoinColumn(name="recipe_id") +// private Recipe recipe; +// +// /** +// * @return the parent recipe +// */ +// public Recipe getRecipe() { +// return recipe; +// } +// +// /** +// * @param recipe the parent recipe to set +// */ +// public void setRecipe(Recipe recipe) { +// this.recipe = recipe; +// } + + public Category() { + } + + public String getCategory() { + return this.category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Long getId() { + return this.id; + } + + public void setId(Long id) { + this.id = id; + } + + @Override + public String toString() { + return this.getCategory(); + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/application.yml b/src/main/resources/META-INF/resources/application.yml new file mode 100644 index 0000000..2492c02 --- /dev/null +++ b/src/main/resources/META-INF/resources/application.yml @@ -0,0 +1,11 @@ +server: + context-path: /codenotfound + port: 9090 + +spring: + datasource: + url: jdbc:sqlite:/home/timh/foo/bazz/recipes.db + jpa: + hibernate: + ddl-auto: none + database-platform: org.sqlite.hibernate.dialect.SQLiteDialect diff --git a/src/main/resources/META-INF/resources/foo.xhtml b/src/main/resources/META-INF/resources/foo.xhtml new file mode 100644 index 0000000..38650a8 --- /dev/null +++ b/src/main/resources/META-INF/resources/foo.xhtml @@ -0,0 +1,23 @@ + + + + + + PrimeFaces DataTable Example Foo + + + + + + + + + + + + + + +