Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
romelgomez committed Sep 11, 2014
0 parents commit 4b8bc77
Show file tree
Hide file tree
Showing 1,649 changed files with 115,572 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target

# IntelliJ IDEA
.idea
jqtree-spring-mvc-gae-example.iml
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Romel Javier Gomez Herrera

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## jqTree example

http://jqtree-spring-mvc-gae-example.appspot.com/

###Main technologies implemented:

<ul>
<li>jqTree <a href="http://mbraak.github.io/jqTree/">http://mbraak.github.io/jqTree/</a></li>
<li>Spring MVC <a href="http://projects.spring.io/spring-framework/">http://projects.spring.io/spring-framework/</a></li>
<li>Google App Engine API <a href="https://developers.google.com/appengine/docs/java/">https://developers.google.com/appengine/docs/java/</a></li>
</ul>

Version 1 Stable
106 changes: 106 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.springapp</groupId>
<artifactId>jqtree-spring-mvc-gae-example</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jqtree-spring-mvc-gae-example</name>

<properties>
<spring.version>3.2.11.RELEASE</spring.version>
</properties>

<dependencies>

<!-- Todo -> Jackson JSON Mapper -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.2</version>
</dependency>

<!-- Todo -> Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

<!-- Todo -> JAVA Servlet and JSP -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>

<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<!-- Todo -> JTesting Framework -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>

<!-- Todo -> Google App Engine-->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.10</version>
</dependency>

</dependencies>

<build>
<finalName>jqtree-spring-mvc-gae-example</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
78 changes: 78 additions & 0 deletions src/main/java/com/store/app/controller/CategoriesController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.store.app.controller;

import com.store.app.service.TreeServiceInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

/**
* CategoriesController
* User: romel
* Date: 17/07/13
* Time: 09:24 PM
*/

@Controller
@RequestMapping("/")
public class CategoriesController {

TreeServiceInterface treeService;

@Autowired
public CategoriesController(TreeServiceInterface todoListService){
this.treeService = todoListService;
}

@RequestMapping(method = RequestMethod.GET)
public String index() {
return "Categories/index";
}


@RequestMapping(value = "get-tree", method=RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ArrayList<ModelMap> getTree() {

return treeService.getTree();

}

@RequestMapping(value = "new-category", method=RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ModelMap newCategory(@RequestBody ModelMap map) {

String name = map.get("name").toString();
return treeService.save(name);

}

@RequestMapping(value = "delete-category", method=RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ModelMap deleteCategory(@RequestBody ModelMap map) {

return treeService.deleteCategory(map);

}

@RequestMapping(value = "update-tree", method=RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ModelMap updateTree(@RequestBody ModelMap map) {
return treeService.updateTree(map);
}

@RequestMapping(value = "edit-category", method=RequestMethod.POST, headers = "Accept=application/json")
@ResponseBody
public ModelMap editCategory(@RequestBody ModelMap map) {

return treeService.editCategory(map);

}


}
33 changes: 33 additions & 0 deletions src/main/java/com/store/app/domain/Tree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.store.app.domain;

import com.google.appengine.api.datastore.Entity;


public class Tree {
// name,parent,left,right

private static final String TREE_ENTITY = "Tree";
private static final String NAME = "name";
private static final String DESCRIPTION = "description";

private Entity entity = new Entity(TREE_ENTITY,"tree");

// For created new nodo
public Tree(final String name,final String description){
entity.setProperty(NAME, name);
entity.setProperty(DESCRIPTION, description);
}

public String getName() {
return (String) entity.getProperty(NAME);
}

public String getDescription() {
return (String) entity.getProperty(DESCRIPTION);
}

public Entity getEntity() {
return entity;
}

}
52 changes: 52 additions & 0 deletions src/main/java/com/store/app/domain/TreeBranch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.store.app.domain;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;

public class TreeBranch {

// name,parent,left,right

private static final String TREE_ENTITY = "TreeBranch";
private static final String NAME = "name";
private static final String PARENT_ID = "parent_id";
private static final String LEFT = "left";
private static final String RIGHT = "right";

private Entity entity;

// For created new nodo
public TreeBranch(final String name, final String parent_id, final Long left, final Long right,Key parent_entity_key){

entity = new Entity(TREE_ENTITY,parent_entity_key);

entity.setProperty(NAME, name);
entity.setProperty(PARENT_ID, parent_id);
entity.setProperty(LEFT, left);
entity.setProperty(RIGHT, right);

}


public String getName() {
return (String) entity.getProperty(NAME);
}

public String getParent() {
return (String) entity.getProperty(PARENT_ID);
}

public Long getLeft() {
return (Long) entity.getProperty(LEFT);
}

public Long getRight() {
return (Long) entity.getProperty(RIGHT);
}

public Entity getEntity() {
return entity;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.store.app.service;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import org.springframework.stereotype.Service;

@Service
public class DatastoreServiceFactoryImplementation implements DatastoreServiceFactoryInterface {

private DatastoreService datastoreService = DatastoreServiceFactory.getDatastoreService();

public DatastoreService getDatastoreService(){
return datastoreService;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.store.app.service;

import com.google.appengine.api.datastore.DatastoreService;

public interface DatastoreServiceFactoryInterface {
public DatastoreService getDatastoreService();
}
Loading

0 comments on commit 4b8bc77

Please sign in to comment.