Skip to content

Commit c5ee31e

Browse files
bugfixing
1 parent a205b83 commit c5ee31e

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

src/main/java/org/woehlke/twitterwall/oodm/service/impl/DomainServiceWithTaskImpl.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,47 +38,47 @@ public T store(T domainObject, Task task) {
3838
String msg = "store "+domainObject.getUniqueId()+" in Task "+task.getId()+" "+task.getTaskType()+" ";
3939
T domainObjectResult = null;
4040
try {
41-
task.setTimeLastUpdate();
42-
task = this.taskRepository.save(task);
43-
T domainObjectPersistent = null;
44-
T storedObject = null;
45-
if(domainObject.getId() != null){
46-
storedObject = domainRepository.findOne(domainObject.getId());
47-
if(storedObject!=null) {
48-
if(storedObject.getUniqueId().compareTo(domainObject.getUniqueId())==0) {
49-
domainObjectPersistent = storedObject;
50-
} else {
51-
domainObjectPersistent = null;
52-
log.error(msg+"Something strange happened!");
53-
log.debug(msg+"tried to persist: " + domainObject.toString());
54-
log.debug(msg+"found: " + domainObjectPersistent.toString());
41+
task.setTimeLastUpdate();
42+
task = this.taskRepository.save(task);
43+
T domainObjectPersistent = null;
44+
T storedObject = null;
45+
if(domainObject.getId() != null){
46+
storedObject = domainRepository.findOne(domainObject.getId());
47+
if(storedObject!=null) {
48+
if(storedObject.getUniqueId().compareTo(domainObject.getUniqueId())==0) {
49+
domainObjectPersistent = storedObject;
50+
} else {
51+
domainObjectPersistent = null;
52+
log.error(msg+"Something strange happened!");
53+
log.debug(msg+"tried to persist: " + domainObject.toString());
54+
log.debug(msg+"found: " + domainObjectPersistent.toString());
55+
}
5556
}
5657
}
57-
}
58-
if(domainObjectPersistent!=null){
59-
//try {
60-
domainObjectPersistent = domainRepository.findByUniqueId(domainObject);
61-
//} catch (Exception e){
62-
// log.debug(msg+ e.getMessage());
63-
// //e.printStackTrace();
64-
// }
65-
}
66-
if (domainObjectPersistent != null) {
67-
domainObject.setId(domainObjectPersistent.getId());
68-
domainObject.setTaskInfo(domainObjectPersistent.getTaskInfo());
69-
domainObject.setCreatedBy(domainObjectPersistent.getCreatedBy());
70-
domainObject.setUpdatedBy(task);
71-
storedObject = domainRepository.save(domainObject);
72-
domainObjectResult = storedObject;
73-
log.debug(msg+"merged: " + domainObjectResult.toString());
74-
} else {
75-
domainObject.setCreatedBy(task);
76-
domainObject.setUpdatedBy(task);
77-
log.debug("try to persist: " + domainObject.toString());
78-
storedObject = domainRepository.save(domainObject);
79-
domainObjectResult = storedObject;
80-
log.debug("persisted: " + domainObjectResult.toString());
81-
}
58+
if(domainObjectPersistent==null){
59+
//try {
60+
domainObjectPersistent = domainRepository.findByUniqueId(domainObject);
61+
//} catch (Exception e){
62+
// log.debug(msg+ e.getMessage());
63+
// //e.printStackTrace();
64+
// }
65+
}
66+
if (domainObjectPersistent != null) {
67+
domainObject.setId(domainObjectPersistent.getId());
68+
domainObject.setTaskInfo(domainObjectPersistent.getTaskInfo());
69+
domainObject.setCreatedBy(domainObjectPersistent.getCreatedBy());
70+
domainObject.setUpdatedBy(task);
71+
storedObject = domainRepository.save(domainObject);
72+
domainObjectResult = storedObject;
73+
log.debug(msg+"merged: " + domainObjectResult.toString());
74+
} else {
75+
domainObject.setCreatedBy(task);
76+
domainObject.setUpdatedBy(task);
77+
log.debug("try to persist: " + domainObject.toString());
78+
storedObject = domainRepository.save(domainObject);
79+
domainObjectResult = storedObject;
80+
log.debug("persisted: " + domainObjectResult.toString());
81+
}
8282
} catch (Exception e) {
8383
log.warn(msg,e.getMessage());
8484
e.printStackTrace();

0 commit comments

Comments
 (0)