1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.extend.modules.comment.service;
35
36 import java.util.Arrays;
37
38 import fr.paris.lutece.plugins.extend.modules.comment.business.Comment;
39 import fr.paris.lutece.plugins.extend.modules.comment.service.extender.CommentResourceExtender;
40 import fr.paris.lutece.plugins.extend.service.extender.facade.ExtenderType;
41 import fr.paris.lutece.plugins.extend.service.extender.facade.ResourceExtenderServiceFacade;
42 import fr.paris.lutece.portal.service.plugin.Plugin;
43 import fr.paris.lutece.portal.service.plugin.PluginDefaultImplementation;
44 import fr.paris.lutece.portal.service.plugin.PluginService;
45 import fr.paris.lutece.portal.service.spring.SpringContextService;
46
47
48
49
50
51
52 public class CommentPlugin extends PluginDefaultImplementation
53 {
54
55 public static final String PLUGIN_NAME = "extend-comment";
56
57
58 public static final String TRANSACTION_MANAGER = PLUGIN_NAME + ".transactionManager";
59
60
61
62
63
64
65 public static Plugin getPlugin( )
66 {
67 return PluginService.getPlugin( PLUGIN_NAME );
68 }
69 @Override
70 public void init( )
71 {
72 super.init( );
73 ICommentService commentService= SpringContextService.getBean( CommentService.BEAN_SERVICE );
74
75
76 ResourceExtenderServiceFacade.addExtenderType(
77 new ExtenderType< >(
78 Comment.class,
79 CommentResourceExtender.EXTENDER_TYPE_COMMENT,
80 (strIdExtendableResource,strExtendableResourceType)-> commentService.findByListResource(Arrays.asList(strIdExtendableResource), strExtendableResourceType),
81 commentService::findByListResource,
82 (strIdExtendableResource,strExtendableResourceType) -> String.valueOf( commentService.getCommentNb( strIdExtendableResource, strExtendableResourceType, true, true )),
83 (strIdExtendableResource,strExtendableResourceType)-> String.valueOf( commentService.getCommentNb( strIdExtendableResource, strExtendableResourceType, true, true )) )
84 );
85 }
86 }