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.genericattributes.modules.ocr.service;
35
36 import java.util.List;
37
38 import org.apache.commons.fileupload.FileItem;
39
40 import fr.paris.lutece.plugins.genericattributes.business.IOcrProvider;
41 import fr.paris.lutece.plugins.genericattributes.business.Response;
42 import fr.paris.lutece.plugins.genericattributes.modules.ocr.exceptions.CallOcrException;
43 import fr.paris.lutece.plugins.genericattributes.modules.ocr.utils.OcrProviderUtils;
44 import fr.paris.lutece.portal.service.util.AppPropertiesService;
45 import fr.paris.lutece.util.ReferenceItem;
46 import fr.paris.lutece.util.ReferenceList;
47
48
49
50
51
52
53 public class OcrCniProvider implements IOcrProvider
54 {
55 private static final long serialVersionUID = 6224042984367506762L;
56 private static final String PROPERTY_KEY = "genericattributes-ocr.CNI.key";
57 private static final String PROPERTY_DISPLAYED_NAME = "genericattributes-ocr.CNI.displayName";
58 private static final String PROPERTY_AUTHORIZED_ENTRY_TYPE = "genericattributes-ocr.CNI.authorizedEntryType";
59
60
61
62
63 @Override
64 public String getKey( )
65 {
66 return AppPropertiesService.getProperty( PROPERTY_KEY );
67 }
68
69
70
71
72 @Override
73 public String getDisplayedName( )
74 {
75 return AppPropertiesService.getProperty( PROPERTY_DISPLAYED_NAME );
76 }
77
78
79
80
81 @Override
82 public ReferenceItem toRefItem( )
83 {
84 ReferenceItem refItem = new ReferenceItem( );
85
86 refItem.setCode( getKey( ) );
87 refItem.setName( getDisplayedName( ) );
88
89 return refItem;
90 }
91
92
93
94
95 @Override
96 public String toString( )
97 {
98 return "Ocr CNI Provider";
99 }
100
101
102
103
104 @Override
105 public Object getParameter( int nKey )
106 {
107
108 return null;
109 }
110
111
112
113
114 @Override
115 public ReferenceList getListField( )
116 {
117 ReferenceList refListField = new ReferenceList( );
118
119 refListField.addItem( 0, "First Name" );
120 refListField.addItem( 1, "Last Name" );
121 refListField.addItem( 2, "Birth date" );
122 refListField.addItem( 3, "Place of Birth" );
123 refListField.addItem( 4, "Expiration date" );
124 refListField.addItem( 5, "isuue date" );
125 refListField.addItem( 6, "Gender" );
126 refListField.addItem( 7, "Nationality" );
127 refListField.addItem( 8, "id number" );
128 refListField.addItem( 9, "Address" );
129
130 return refListField;
131 }
132
133
134
135
136 @Override
137 public ReferenceItem getFieldById( int idField )
138 {
139 return getListField( ).get( idField );
140 }
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156 @Override
157 public List<Response> process( FileItem fileUploaded, int nIdTargetEntry, String strResourceType ) throws CallOcrException
158 {
159 return OcrProviderUtils.process( fileUploaded, nIdTargetEntry, strResourceType, getKey( ), getListField( ) );
160 }
161
162 @Override
163 public String getConfigHtmlCode( ReferenceList lisEntry, int nIdQuestion, String strResourceType )
164 {
165
166 return OcrProviderUtils.builtTempalteConfiog( lisEntry, this, nIdQuestion, strResourceType ).getHtml( );
167 }
168
169 @Override
170 public String getHtmlCode( int nIdTargetEntry, String strResourceType )
171 {
172
173 return OcrProviderUtils.builtTempalteCode( nIdTargetEntry, strResourceType ).getHtml( );
174 }
175 }