some events

This commit is contained in:
lukasgol committed 2015-02-11 22:56:21 +01:00
1 parent 1e281381f2
commit 2b657edec9
18 files changed
+438 -115

No files matched your search

+41 -49
View File
@@ -4,28 +4,18 @@
<facet type="Spring" name="Spring">
<configuration>
<fileset id="fileset" name="Spring Application Context" removed="false">
<file>file://$MODULE_DIR$/src/main/java/application/Config.java</file>
<file>file://$MODULE_DIR$/src/main/resources/Spring-Module.xml</file>
</fileset>
</configuration>
</facet>
<facet type="hibernate" name="Hibernate">
<configuration>
<datasource-map>
<unit-entry name="hibernate.cfg.xml" />
</datasource-map>
<naming-strategy-map />
<deploymentDescriptor name="hibernate.cfg.xml" url="file://$MODULE_DIR$/src/main/resources/hibernate.cfg.xml" />
</configuration>
</facet>
<facet type="web" name="Web Gradle : nfc_server-0.1.0.war">
<configuration>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/src/main/resources" />
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
@@ -44,69 +34,71 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Gradle: javax.servlet:jstl:1.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: junit:junit:4.11" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-data-jpa:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.h2database:h2:1.3.175" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.json:json:20080701" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-web:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.google.code.gson:gson:2.2.4" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-core:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.3.0" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-core:2.3.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-beans:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-aop:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-expression:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-context:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-autoconfigure:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:slf4j-api:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:jcl-over-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:jul-to-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:log4j-over-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: ch.qos.logback:logback-core:1.1.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: ch.qos.logback:logback-classic:1.1.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-logging:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-aop:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-jdbc:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate:hibernate-entitymanager:4.3.1.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-orm:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.data:spring-data-jpa:1.5.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-aspects:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-tomcat:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-web:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-webmvc:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-aop:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.aspectj:aspectjrt:1.7.4" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.aspectj:aspectjweaver:1.7.4" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-aop:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.yaml:snakeyaml:1.13" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-tx:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-jdbc:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat:tomcat-juli:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat:tomcat-jdbc:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-jdbc:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-tx:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.jboss.logging:jboss-logging:3.1.3.GA" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.jboss.logging:jboss-logging-annotations:1.2.0.Beta1" level="project" />
<orderEntry type="library" exported="" name="Gradle: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate:hibernate-core:4.3.1.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: dom4j:dom4j:1.6.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate.common:hibernate-commons-annotations:4.0.4.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:1.0.0.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.javassist:javassist:3.18.1-GA" level="project" />
<orderEntry type="library" exported="" name="Gradle: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.jboss:jandex:1.1.0.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate:hibernate-core:4.3.1.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hibernate:hibernate-entitymanager:4.3.1.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-orm:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-beans:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.data:spring-data-commons:1.7.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.data:spring-data-jpa:1.5.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-aspects:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:slf4j-api:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:jcl-over-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-autoconfigure:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-logging:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.yaml:snakeyaml:1.13" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat.embed:tomcat-embed-core:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat.embed:tomcat-embed-el:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework.boot:spring-boot-starter-tomcat:1.0.0.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-web:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-webmvc:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" exported="" scope="RUNTIME" name="Gradle: javax.servlet:jstl:1.2" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-expression:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.apache.tomcat:tomcat-juli:7.0.52" level="project" />
<orderEntry type="library" exported="" name="Gradle: antlr:antlr:2.7.7" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.jboss:jandex:1.1.0.Final" level="project" />
<orderEntry type="library" exported="" name="Gradle: xml-apis:xml-apis:1.0.b2" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:jul-to-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.slf4j:log4j-over-slf4j:1.7.6" level="project" />
<orderEntry type="library" exported="" name="Gradle: ch.qos.logback:logback-classic:1.1.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: ch.qos.logback:logback-core:1.1.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-core:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.springframework:spring-context:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: commons-logging:commons-logging:1.1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.springframework.boot:spring-boot-starter-test:1.0.0.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.springframework:spring-test:4.0.3.RELEASE" level="project" />
<orderEntry type="library" exported="" name="Gradle: junit:junit:4.11" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.mockito:mockito-core:1.10.19" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.objenesis:objenesis:2.1" level="project" />
<orderEntry type="library" exported="" name="Gradle: org.reflections:reflections:0.9.9-RC1" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" exported="" name="Gradle: com.google.guava:guava:11.0.2" level="project" />
</component>
</module>
-1
View File
@@ -38,7 +38,6 @@ dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile("org.springframework.boot:spring-boot-starter-test")
providedRuntime("javax.servlet:jstl")
compile 'com.google.code.gson:gson:2.2.4'
compile "org.mockito:mockito-core:1.+"
compile "org.reflections:reflections:0.9.9-RC1"
Binary file not shown.
+2 -2
View File
@@ -1,6 +1,6 @@
#Wed Apr 02 00:24:51 CEST 2014
#Mon Dec 15 22:59:12 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip
+6 -6
View File
@@ -1,8 +1,6 @@
package application;
import application.events.EventObject;
import application.events.impl.EntryEvent;
import application.events.impl.EventObjectImpl;
import application.model.User;
import application.repositories.*;
import application.utils.Initializer;
@@ -17,6 +15,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
@@ -29,6 +28,7 @@ import org.springframework.web.servlet.view.JstlView;
@EnableAutoConfiguration
@ImportResource("Spring-Module.xml")
@EnableScheduling
@EnableWebMvc
public class Config extends SpringBootServletInitializer {
@@ -43,13 +43,13 @@ public class Config extends SpringBootServletInitializer {
UserRepository userRepository = context.getBean(UserRepository.class);
RoleRepository roleRepository = context.getBean(RoleRepository.class);
DoorRepository doorRepository = context.getBean(DoorRepository.class);
EventRepositoriy eventRepositoriy = context.getBean(EventRepositoriy.class);
EntryEventRepository entryEventRepository = context.getBean(EntryEventRepository.class);
HistoryEntryRepository historyEntryRepository = context.getBean(HistoryEntryRepository.class);
new Initializer(roleRepository, userRepository, doorRepository, historyEntryRepository).init();
User user =new User("aa","bb","cc","dd");
eventRepositoriy.save(new EntryEvent(1,1,2));
eventRepositoriy.save(new EntryEvent(1,2,2));
eventRepositoriy.save(new EntryEvent(2,1,2));
entryEventRepository.save(new EntryEvent(1,1,2));
entryEventRepository.save(new EntryEvent(1,2,2));
entryEventRepository.save(new EntryEvent(2,1,2));
}
@@ -0,0 +1,30 @@
package application.Notification;
/**
* Created by lukasgol on 16.12.14.
*/
public class NotificationMessage {
String title;
String msg;
public NotificationMessage(String msg) {
this.msg = msg;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
@@ -0,0 +1,35 @@
package application.Notification;
/**
* Created by lukasgol on 16.12.14.
*/
public class NotificationRequest {
String registration_ids;
String data;
/* public NotificationRequest(String registration_ids, String data) {
this.registration_ids = "[\""+registration_ids+"\"]";
this.data = "{\"message\" : \""+data+"\"}";
}*/
public NotificationRequest(String registration_ids, String data) {
this.registration_ids = registration_ids;
this.data = data;
}
public String getRegistration_ids() {
return registration_ids;
}
public void setRegistration_ids(String registration_ids) {
this.registration_ids = registration_ids;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
@@ -0,0 +1,61 @@
package application.Notification;
/**
* Created by lukasgol on 16.12.14.
*/
public class NotificationResponse {
String multicast_id;
String success;
String failure;
String canonical_ids;
String results;
public String getMulticast_id() {
return multicast_id;
}
public void setMulticast_id(String multicast_id) {
this.multicast_id = multicast_id;
}
public String getFailure() {
return failure;
}
public void setFailure(String failure) {
this.failure = failure;
}
public String getCanonical_ids() {
return canonical_ids;
}
public void setCanonical_ids(String canonical_ids) {
this.canonical_ids = canonical_ids;
}
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
public String getResults() {
return results;
}
public void setResults(String results) {
this.results = results;
}
public NotificationResponse(String multicast_id, String success, String failure, String canonical_ids, String results) {
this.multicast_id = multicast_id;
this.success = success;
this.failure = failure;
this.canonical_ids = canonical_ids;
this.results = results;
}
}
@@ -2,24 +2,15 @@ package application.controllers;
import application.Constants;
import application.events.EventManager;
import application.events.EventObject;
import application.events.impl.DoorLockedEvent;
import application.events.impl.EntryEvent;
import application.model.Door;
import application.model.User;
import application.events.impl.MainDoorEntryEvent;
import application.network.response.BaseResponse;
import application.repositories.DoorRepository;
import application.repositories.EventRepositoriy;
import application.repositories.UserRepository;
import application.repositories.*;
import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.List;
import org.springframework.web.bind.annotation.*;
/**
* Created by lukasgol on 10.02.15.
@@ -29,7 +20,13 @@ import java.util.List;
public class EventController {
@Autowired
EventRepositoriy eventRepositoriy;
EntryEventRepository entryEventRepository;
@Autowired
MainDoorEntryEventRepository mainDoorEntryEventRepository;
@Autowired
DoorLockedEventRepository doorLockedEventRepository;
@Autowired
UserRepository userRepository;
@@ -41,28 +38,100 @@ public class EventController {
EventManager eventManager;
@RequestMapping(value = "/eventEntry")
@RequestMapping(value = "/{doorId}/{userId}")
@ResponseBody
public BaseResponse entryEventTrigger(@RequestBody long userId, @RequestBody long doorId) throws JSONException {
public BaseResponse entryEventTrigger(@RequestParam("userId") long userId ,@RequestParam("doorId") long doorId) throws JSONException {
for(EntryEvent e: eventRepositoriy.findAll()){
for(EntryEvent e: entryEventRepository.findAll()){
if(e.getWho()==userId&&e.getDoor()==doorId)
eventManager.sendNotification(e);
}
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
/* Entry event*/
@RequestMapping(value = "/eventEntry/add")
@ResponseBody
public BaseResponse addEventTrigger(@RequestBody long userId, @RequestBody long doorId,@RequestBody long who) throws JSONException {
eventRepositoriy.save(new EntryEvent(doorId,who,userId));
public BaseResponse addEntry(@RequestParam long userId, @RequestParam long doorId,@RequestParam long who) throws JSONException {
entryEventRepository.save(new EntryEvent(doorId,who,userId));
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
@RequestMapping(value = "/eventEntry/getAll")
@ResponseBody
public Iterable<EntryEvent> getAll() throws JSONException {
Iterable<EntryEvent> a =eventRepositoriy.findAll();
return eventRepositoriy.findAll();
public Iterable<EntryEvent> getAllEntry() throws JSONException {
Iterable<EntryEvent> a = entryEventRepository.findAll();
return entryEventRepository.findAll();
}
@RequestMapping(value = "/eventEntry/get/{id}")
@ResponseBody
public EntryEvent getEntry(@PathVariable("id") long id) throws JSONException {
return entryEventRepository.findOne(id);
}
@RequestMapping(value = "/eventEntry/remove/{id}")
@ResponseBody
public BaseResponse removeEntry(@PathVariable("id") long id) throws JSONException {
entryEventRepository.delete(id);
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
/*Main door event*/
@RequestMapping(value = "/MainDoorEntry/add")
@ResponseBody
public BaseResponse addMainDoorEntry(@RequestParam long doorId ) throws JSONException {
mainDoorEntryEventRepository.save(new MainDoorEntryEvent(doorId));
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
@RequestMapping(value = "/MainDoorEntry/getAll")
@ResponseBody
public Iterable<MainDoorEntryEvent> getAllMainDoorEntry() throws JSONException {
return mainDoorEntryEventRepository.findAll();
}
@RequestMapping(value = "/MainDoorEntry/get/{id}")
@ResponseBody
public MainDoorEntryEvent getMainDoorEntry(@PathVariable("id") long id) throws JSONException {
return mainDoorEntryEventRepository.findOne(id);
}
@RequestMapping(value = "/MainDoorEntry/remove/{id}")
@ResponseBody
public BaseResponse removeMainDoorEntry(@PathVariable("id") long id) throws JSONException {
mainDoorEntryEventRepository.delete(id);
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
/*locked door event*/
@RequestMapping(value = "/DoorLockedEntry/add")
@ResponseBody
public BaseResponse addDoorLockedEntry(@RequestParam long doorId, @RequestParam String why) throws JSONException {
doorLockedEventRepository.save(new DoorLockedEvent(doorId,why));
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
@RequestMapping(value = "/DoorLockedEntry/getAll")
@ResponseBody
public Iterable<DoorLockedEvent> getAllDoorLockedEntry() throws JSONException {
return doorLockedEventRepository.findAll();
}
@RequestMapping(value = "/DoorLockedEntry/get/{id}")
@ResponseBody
public DoorLockedEvent getDoorLockedEntry(@PathVariable("id") long id) throws JSONException {
return doorLockedEventRepository.findOne(id);
}
@RequestMapping(value = "/DoorLockedEntry/remove/{id}")
@ResponseBody
public BaseResponse removeDoorLockedEntry(@PathVariable("id") long id) throws JSONException {
doorLockedEventRepository.delete(id);
return new BaseResponse().init(Constants.SUCCESS_TRUE);
}
}
@@ -15,8 +15,8 @@ public class EventManager {
Set<Class<? extends EventObject>> eventClassSet;
Set<EventObject> eventsSet;
public EventManager() {
eventClassSet = findEventClasses();
eventsSet = instantiateEvents(eventClassSet);
/* eventClassSet = findEventClasses();
eventsSet = instantiateEvents(eventClassSet);*/
System.out.println("Class EventManagerCreated");
}
@@ -0,0 +1,73 @@
package application.events.impl;
import application.events.EventObject;
import javax.persistence.*;
/**
* Created by lukasgol on 11.02.15.
*/
@Entity
public class DoorLockedEvent implements EventObject {
@Override
public void validEvent() {
}
@Override
public void handleEvent() {
}
@Override
public boolean isValid() {
return false;
}
@Override
public String createMessage() {
return null;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Basic
private Long user;
@Basic String reason;
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public DoorLockedEvent(Long user, String reason) {
this.user = user;
this.reason = reason;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public DoorLockedEvent() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@@ -19,7 +19,7 @@ public class EntryEvent implements EventObject {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long entryEventId;
private Long id;
@Basic
private Long door;
@@ -94,4 +94,12 @@ public class EntryEvent implements EventObject {
public String createMessage() {
return "User: "+who+" passed through door: " +door;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@@ -1,31 +0,0 @@
package application.events.impl;
import application.events.EventObject;
import application.model.User;
/**
* Created by lukasgol on 01.02.15.
*/
public class EventObjectImpl implements EventObject {
public User user;
@Override
public void validEvent() {
System.out.println("Chceking event: "+this.getClass().getName());
}
@Override
public void handleEvent() {
System.out.println("sending notification for event: "+this.getClass().getName());
}
@Override
public boolean isValid() {
return true;
}
@Override
public String createMessage() {
return "User: "+user.getFirstName()+" "+user.getLastName()+" passed through door" ;
}
}
@@ -0,0 +1,65 @@
package application.events.impl;
import application.events.EventObject;
import javax.persistence.*;
/**
* Created by lukasgol on 11.02.15.
*/
@Entity
public class MainDoorEntryEvent implements EventObject {
@Basic
private Long who;
@Override
public void validEvent() {
}
@Override
public void handleEvent() {
}
@Override
public boolean isValid() {
return false;
}
@Override
public String createMessage() {
return null;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
public Long getWho() {
return who;
}
public void setWho(Long who) {
this.who = who;
}
public MainDoorEntryEvent(Long who) {
this.who = who;
}
public MainDoorEntryEvent() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
@@ -0,0 +1,10 @@
package application.repositories;
import application.events.impl.DoorLockedEvent;
import org.springframework.data.repository.CrudRepository;
/**
* Created by lukasgol on 11.02.15.
*/
public interface DoorLockedEventRepository extends CrudRepository<DoorLockedEvent, Long> {
}
@@ -6,6 +6,6 @@ import org.springframework.data.repository.CrudRepository;
/**
* Created by lukasgol on 01.02.15.
*/
public interface EventRepositoriy extends CrudRepository<EntryEvent, Long>
public interface EntryEventRepository extends CrudRepository<EntryEvent, Long>
{
}
@@ -0,0 +1,11 @@
package application.repositories;
import application.events.impl.EntryEvent;
import application.events.impl.MainDoorEntryEvent;
import org.springframework.data.repository.CrudRepository;
/**
* Created by lukasgol on 11.02.15.
*/
public interface MainDoorEntryEventRepository extends CrudRepository<MainDoorEntryEvent, Long> {
}
+1
View File
@@ -1,2 +1,3 @@
server.port=8181
my.prop=avalue
lala=lala