Skip to content

Commit

Permalink
Merge pull request #8 from antespajic/ante-development
Browse files Browse the repository at this point in the history
Final push of this version
  • Loading branch information
antespajic authored Apr 7, 2017
2 parents 9edc056 + b7f400b commit cf7d050
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 67 deletions.
110 changes: 51 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,13 @@
[
{
"wish" : {
"wishId" : 1744,
"userId" : 1980,
"id" : "1744",
"creator" : {
"userId" : "1980",
"firstName" : "Bill",
"lastName" : "Kent",
"profilePicture" : "profile/picture/url"
},
"title" : "Wish title here",
"description" : "Wish description here",
"categories" : [ "travel", "music", "dancing" ],
Expand All @@ -654,14 +659,7 @@
"offerId" : null,
"state" : 1,
"upvoteCount" : 0,
"reportCount" : 0
},
"creator" : {
"userId" : 1980,
"firstName" : "Bill",
"lastName" : "Kent",
"profilePicture" : "profile/picture/url"
}
}
]
```
Expand All @@ -679,26 +677,24 @@
[
{
"story" : {
"id" : 6731,
"wishId" : 148842,
"creatorId" : 15561,
"sponsorId" : 27888,
"id" : "6731da",
"wishId" : "12sd312",
"creator" : {
"id" : "d112312d",
"firstName" : "Jane",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
},
"sponsor" : {
"id" : "d2e2123",
"firstName" : "John",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
}
"description" : "Story description here",
"created" : 1490117226,
"pictures" : [ "url/to/first/picture", "url/to/last/picture" ],
"reportCount" : 0
},
"creator" : {
"userId" : 15561,
"firstName" : "Jane",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
},
"sponsor" : {
"userId" : 27888,
"firstName" : "John",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
}
}
]
Expand All @@ -718,8 +714,13 @@
[
{
"wish" : {
"wishId" : 1744,
"userId" : 1980,
"id" : "1744",
"creator" : {
"userId" : "1980",
"firstName" : "Bill",
"lastName" : "Kent",
"profilePicture" : "profile/picture/url"
},
"title" : "Wish title here",
"description" : "Wish description here",
"categories" : [ "travel", "music", "dancing" ],
Expand All @@ -728,18 +729,11 @@
"offerId" : null,
"state" : 1,
"upvoteCount" : 0,
"reportCount" : 0
},
"creator" : {
"userId" : 1980,
"firstName" : "Bill",
"lastName" : "Kent",
"profilePicture" : "profile/picture/url"
"interaction" : {
"upvoted" : false,
"reported" : false
}
},
"interaction" : {
"upvoted" : false,
"reported" : false
}
}
]
```
Expand All @@ -758,30 +752,28 @@
[
{
"story" : {
"id" : 6731,
"wishId" : 148842,
"creatorId" : 15561,
"sponsorId" : 27888,
"id" : "6731da",
"wishId" : "12sd312",
"creator" : {
"id" : "d112312d",
"firstName" : "Jane",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
},
"sponsor" : {
"id" : "d2e2123",
"firstName" : "John",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
}
"description" : "Story description here",
"created" : 1490117226,
"pictures" : [ "url/to/first/picture", "url/to/last/picture" ],
"reportCount" : 0
},
"creator" : {
"userId" : 15561,
"firstName" : "Jane",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
},
"sponsor" : {
"userId" : 27888,
"firstName" : "John",
"lastName" : "Doe",
"profilePicture" : "profile/picture/url"
},
"interaction" : {
"upvoted" : false,
"reported" : false
"reportCount" : 0,
"interaction" : {
"upvoted" : false,
"reported" : false
}
}
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
public class StoryElasticModel {

@Id private String id;
private String wishId;
private String description;
private List<String> pictures;
@Field(type = FieldType.Nested) private UserLightViewModel creator;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/hr/asc/appic/mapping/StoryMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public StoryElasticModel toElasticModel(Story story,
.created(String.valueOf(story.getCreated().getTime()))
.description(story.getDescription())
.id(story.getId())
.wishId(story.getWish().getId())
.pictures(story.getPictures()).build();
}
}
22 changes: 14 additions & 8 deletions src/main/java/hr/asc/appic/service/StoryService.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package hr.asc.appic.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.context.request.async.DeferredResult;

import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;

import hr.asc.appic.controller.model.StoryExportModel;
import hr.asc.appic.controller.model.StoryModel;
import hr.asc.appic.controller.model.UserLightViewModel;
Expand All @@ -17,12 +25,6 @@
import hr.asc.appic.persistence.repository.UserRepository;
import hr.asc.appic.persistence.repository.WishRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.context.request.async.DeferredResult;

@Slf4j
@Service
Expand Down Expand Up @@ -131,8 +133,12 @@ public DeferredResult<ResponseEntity> updateStory(String id, StoryModel model) {
Assert.notNull(story, "Could not find story with id: " + id);

storyMapper.updatePojoFromModel(story, model);
storyRepository.save(story);

story = storyRepository.save(story).get();
storyElasticRepository.save(storyMapper.toElasticModel(
story,
userMapper.lightModelFromUser(story.getCreator()),
userMapper.lightModelFromUser(story.getSponsor()))
);
return null;
}
);
Expand Down

0 comments on commit cf7d050

Please sign in to comment.