Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit fefacf7

Browse files
committed
Version 2.0.0
1 parent 7967948 commit fefacf7

13 files changed

+890
-165
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.groupdocs.ui.servlet;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.groupdocs.annotation.domain.AnnotationInfo;
5+
import com.groupdocs.annotation.domain.Point;
6+
import com.groupdocs.annotation.domain.TextFieldInfo;
7+
import com.groupdocs.annotation.domain.results.DeleteAnnotationResult;
8+
import com.groupdocs.annotation.domain.results.MoveAnnotationResult;
9+
import com.groupdocs.annotation.domain.results.SaveAnnotationTextResult;
10+
import com.groupdocs.annotation.handler.AnnotationImageHandler;
11+
import com.groupdocs.ui.Utils;
12+
13+
import javax.servlet.ServletException;
14+
import javax.servlet.annotation.WebServlet;
15+
import javax.servlet.http.HttpServlet;
16+
import javax.servlet.http.HttpServletRequest;
17+
import javax.servlet.http.HttpServletResponse;
18+
import java.io.IOException;
19+
20+
@WebServlet("/annotation")
21+
public class AnnotationServlet extends HttpServlet {
22+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
23+
response.setHeader("Content-Type", "application/json");
24+
25+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
26+
String guid = request.getParameter("guid");
27+
28+
new ObjectMapper().writeValue(response.getOutputStream(), imageHandler.getAnnotation(guid).getAnnotation());
29+
}
30+
31+
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32+
response.setHeader("Content-Type", "application/json");
33+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
34+
35+
String guid = request.getParameter("guid");
36+
long annotationId = imageHandler.getAnnotation(guid).getId();
37+
38+
DeleteAnnotationResult result = imageHandler.deleteAnnotation(annotationId);
39+
new ObjectMapper().writeValue(response.getOutputStream(), result);
40+
41+
}
42+
43+
@Override
44+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
45+
response.setHeader("Content-Type", "application/json");
46+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
47+
String guid = request.getParameter("guid");
48+
String section = request.getParameter("section");
49+
AnnotationInfo annotationInfo = imageHandler.getAnnotation(guid).getAnnotation();
50+
long annotationId = imageHandler.getAnnotation(guid).getId();
51+
52+
switch (section) {
53+
case "fieldtext":
54+
TextFieldInfo info = new ObjectMapper().readValue(request.getInputStream(), TextFieldInfo.class);
55+
SaveAnnotationTextResult result = imageHandler.saveTextField(annotationId, info);
56+
new ObjectMapper().writeValue(response.getOutputStream(), result);
57+
break;
58+
case "position":
59+
Point point = new ObjectMapper().readValue(request.getInputStream(), Point.class);
60+
imageHandler.moveAnnotationMarker(annotationId, point, annotationInfo.getPageNumber());
61+
break;
62+
default:
63+
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
64+
break;
65+
}
66+
}
67+
}
68+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.groupdocs.ui.servlet;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.groupdocs.annotation.domain.AnnotationReplyInfo;
5+
import com.groupdocs.annotation.domain.results.AddReplyResult;
6+
import com.groupdocs.annotation.domain.results.GetAnnotationResult;
7+
import com.groupdocs.annotation.handler.AnnotationImageHandler;
8+
import com.groupdocs.ui.Utils;
9+
10+
import javax.servlet.ServletException;
11+
import javax.servlet.annotation.WebServlet;
12+
import javax.servlet.http.HttpServlet;
13+
import javax.servlet.http.HttpServletRequest;
14+
import javax.servlet.http.HttpServletResponse;
15+
import java.io.IOException;
16+
17+
@WebServlet("/replies")
18+
public class RepliesServlet extends HttpServlet {
19+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
20+
response.setHeader("Content-Type", "application/json");
21+
22+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
23+
String guid = request.getParameter("guid");
24+
25+
GetAnnotationResult annotationResult = imageHandler.getAnnotation(guid);
26+
if (annotationResult == null) {
27+
response.sendError(HttpServletResponse.SC_NOT_FOUND);
28+
return;
29+
}
30+
long annotationId = annotationResult.getId();
31+
AnnotationReplyInfo[] list = imageHandler.listAnnotationReplies(annotationId).getReplies();
32+
33+
new ObjectMapper().writeValue(response.getOutputStream(), list);
34+
}
35+
36+
@Override
37+
protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
38+
response.setHeader("Content-Type", "application/json");
39+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
40+
41+
AnnotationReplyInfo info = new ObjectMapper().readValue(request.getInputStream(), AnnotationReplyInfo.class);
42+
43+
long annotationId = imageHandler.getAnnotation(info.getGuid()).getId();
44+
45+
AddReplyResult result = imageHandler.createAnnotationReply(annotationId, "");
46+
new ObjectMapper().writeValue(response.getOutputStream(), result);
47+
}
48+
}
49+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.groupdocs.ui.servlet;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.groupdocs.annotation.domain.AnnotationReplyInfo;
5+
import com.groupdocs.annotation.domain.results.DeleteReplyResult;
6+
import com.groupdocs.annotation.handler.AnnotationImageHandler;
7+
import com.groupdocs.ui.Utils;
8+
9+
import javax.servlet.ServletException;
10+
import javax.servlet.annotation.WebServlet;
11+
import javax.servlet.http.HttpServlet;
12+
import javax.servlet.http.HttpServletRequest;
13+
import javax.servlet.http.HttpServletResponse;
14+
import java.io.IOException;
15+
16+
@WebServlet("/reply")
17+
public class ReplyServlet extends HttpServlet {
18+
19+
protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
20+
response.setHeader("Content-Type", "application/json");
21+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
22+
23+
String guid = request.getParameter("guid");
24+
25+
DeleteReplyResult result = imageHandler.deleteAnnotationReply(guid);
26+
new ObjectMapper().writeValue(response.getOutputStream(), result);
27+
28+
}
29+
30+
@Override
31+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
32+
response.setHeader("Content-Type", "application/json");
33+
AnnotationImageHandler imageHandler = Utils.createAnnotationImageHandler();
34+
String guid = request.getParameter("guid");
35+
String section = request.getParameter("section");
36+
37+
switch (section) {
38+
case "message":
39+
AnnotationReplyInfo info = new ObjectMapper().readValue(request.getInputStream(), AnnotationReplyInfo.class);
40+
imageHandler.editAnnotationReply(guid, info.getMessage());
41+
break;
42+
default:
43+
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
44+
break;
45+
}
46+
}
47+
}
48+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
(function () {
2+
'use strict';
3+
4+
function main($rootScope, $scope, AnnotationListFactory, FilesFactory, DocumentInfoFactory) {
5+
6+
$scope.docInfo = DocumentInfoFactory.get();
7+
$scope.selectedFile = FilesFactory.selectedFile;
8+
$scope.annotationsList = AnnotationListFactory.query();
9+
$rootScope.selectedDrawingTool = 'select';
10+
11+
}
12+
13+
angular.module('GroupDocsAnnotationApp').controller('PageCanvasController', main);
14+
15+
})();
16+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
(function () {
2+
'use strict';
3+
4+
function main($rootScope, $scope, $resource, AnnotationFactory, RepliesFactory, ReplyFactory) {
5+
6+
$rootScope.$watch('selectedAnnotationGuid', function () {
7+
$scope.fetchAnnotation();
8+
}, true);
9+
10+
$scope.deleteAnnotation = function (item) {
11+
$rootScope.$broadcast('request-annotation-deletion', item.guid);
12+
};
13+
14+
$scope.saveAnnotationFieldText = function (item) {
15+
AnnotationFactory
16+
.updateFieldText(
17+
{
18+
guid: item.guid
19+
},
20+
{
21+
fieldText: item.fieldText
22+
}
23+
)
24+
.$promise
25+
.then(function (response) {
26+
item.unsaved = false;
27+
});
28+
};
29+
30+
$scope.addReply = function (item) {
31+
RepliesFactory
32+
.put(
33+
{guid: item.guid}
34+
)
35+
.$promise
36+
.then(function (response) {
37+
$scope.fetchAnnotation();
38+
});
39+
};
40+
41+
$scope.deleteReply = function (guid) {
42+
ReplyFactory
43+
.remove({guid: guid})
44+
.$promise
45+
.then(function (response) {
46+
$scope.fetchAnnotation();
47+
});
48+
};
49+
50+
$scope.saveReplyMessage = function (reply) {
51+
ReplyFactory
52+
.updateMessage(
53+
{
54+
guid: reply.guid
55+
},
56+
{
57+
message: reply.message
58+
}
59+
)
60+
.$promise
61+
.then(function (response) {
62+
reply.unsaved = false;
63+
});
64+
};
65+
66+
$scope.fetchAnnotation = function () {
67+
if (typeof($rootScope.selectedAnnotationGuid) === 'string') {
68+
$scope.selectedAnnotation = AnnotationFactory.get({
69+
guid: $rootScope.selectedAnnotationGuid
70+
});
71+
} else {
72+
$scope.selectedAnnotation = null;
73+
}
74+
};
75+
76+
}
77+
78+
angular.module('GroupDocsAnnotationApp').controller('ThreadController', main);
79+
80+
})();
81+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
(function () {
2+
'use strict';
3+
4+
function main($rootScope, $scope) {
5+
6+
$scope.selectRectangleTool = function ($event) {
7+
$rootScope.selectedDrawingTool = 'rectangle';
8+
};
9+
10+
$scope.selectPencilTool = function ($event) {
11+
$rootScope.selectedDrawingTool = 'pencil';
12+
};
13+
$scope.selectSelectTool = function ($event) {
14+
$rootScope.selectedDrawingTool = 'select';
15+
};
16+
$scope.selectPointTool = function ($event) {
17+
$rootScope.selectedDrawingTool = 'point';
18+
};
19+
20+
$scope.selectSelectTool();
21+
}
22+
23+
angular.module('GroupDocsAnnotationApp').controller('ToolsController', main);
24+
25+
})();
26+

0 commit comments

Comments
 (0)