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.pluginwizard.service;
35
36 import fr.paris.lutece.plugins.pluginwizard.business.Model;
37 import fr.paris.lutece.plugins.pluginwizard.business.ModelHome;
38 import fr.paris.lutece.plugins.pluginwizard.business.model.Application;
39 import fr.paris.lutece.plugins.pluginwizard.business.model.Attribute;
40 import fr.paris.lutece.plugins.pluginwizard.business.model.BusinessClass;
41 import fr.paris.lutece.plugins.pluginwizard.business.model.Feature;
42 import fr.paris.lutece.plugins.pluginwizard.business.model.PluginModel;
43 import fr.paris.lutece.plugins.pluginwizard.business.model.Portlet;
44 import fr.paris.lutece.plugins.pluginwizard.business.model.Rest;
45 import fr.paris.lutece.plugins.pluginwizard.web.formbean.BusinessClassFormBean;
46 import fr.paris.lutece.plugins.pluginwizard.web.formbean.ConfigurationFormBean;
47 import fr.paris.lutece.plugins.pluginwizard.web.formbean.DescriptionFormBean;
48 import fr.paris.lutece.portal.service.spring.SpringContextService;
49 import fr.paris.lutece.portal.service.util.AppException;
50 import fr.paris.lutece.util.ReferenceList;
51
52 import com.fasterxml.jackson.databind.DeserializationFeature;
53 import com.fasterxml.jackson.databind.ObjectMapper;
54
55 import java.io.IOException;
56 import java.lang.reflect.InvocationTargetException;
57 import java.util.ArrayList;
58 import java.util.List;
59 import java.util.Locale;
60 import org.apache.commons.beanutils.BeanUtils;
61
62
63
64
65 public final class ModelService
66 {
67 private static AttributeService _serviceAttribute = SpringContextService.getBean( "pluginwizard.attribute.service" );
68 private static ObjectMapper _mapper = new ObjectMapper( ).configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false );
69 private static final String ID = "id";
70 private static final String UNDERSCORE = "_";
71
72
73 private ModelService( )
74 {
75 }
76
77
78
79
80
81
82
83
84 public static int createModel( String strPluginName )
85 {
86 Modelins/pluginwizard/business/Model.html#Model">Model model = new Model( );
87 model.setName( strPluginName );
88
89 PluginModel/pluginwizard/business/model/PluginModel.html#PluginModel">PluginModel pm = new PluginModel( );
90 pm.setPluginName( strPluginName );
91
92 model = ModelHome.create( model );
93 pm.setIdPlugin( model.getIdPlugin( ) );
94 savePluginModel( pm );
95
96 return pm.getIdPlugin( );
97 }
98
99
100
101
102
103
104
105
106 public static PluginModel getPluginModel( int nPluginId )
107 {
108 PluginModel pm;
109 Model model = ModelHome.findByPrimaryKey( nPluginId );
110
111 if ( model != null )
112 {
113 pm = MapperService.readJson( model.getModelJson( ) );
114 }
115 else
116 {
117 pm = new PluginModel( );
118 pm.setIdPlugin( nPluginId );
119 }
120
121 return pm;
122 }
123
124
125
126
127
128
129
130 public static void savePluginModel( PluginModel pm )
131 {
132 Modelins/pluginwizard/business/Model.html#Model">Model model = new Model( );
133 model.setIdPlugin( pm.getIdPlugin( ) );
134 model.setName( pm.getPluginName( ) );
135
136 String strJson = MapperService.getJson( pm );
137 model.setModelJson( strJson );
138
139 if ( ModelHome.findByPrimaryKey( pm.getIdPlugin( ) ) != null )
140 {
141 ModelHome.update( model );
142 }
143 else
144 {
145 ModelHome.create( model );
146 }
147 }
148
149
150
151
152
153
154
155
156 public static int savePluginModelFromJson( PluginModel pm )
157 {
158 Model model;
159 int nPluginId = ModelHome.exists( pm.getPluginName( ) );
160
161 if ( nPluginId == -1 )
162 {
163
164 model = new Model( );
165 model.setName( pm.getPluginName( ) );
166
167 ModelHome.create( model );
168 }
169 else
170 {
171 model = ModelHome.findByPrimaryKey( nPluginId );
172 }
173
174 pm.setIdPlugin( model.getIdPlugin( ) );
175 String strJson = MapperService.getJson( pm );
176 model.setModelJson( strJson );
177 ModelHome.update( model );
178
179 return model.getIdPlugin( );
180 }
181
182
183
184
185
186
187
188
189
190
191
192 public static void addFeature( int nPluginId, Feature feature )
193 {
194 PluginModel pm = getPluginModel( nPluginId );
195 feature.setId( getMaxFeatureId( pm ) + 1 );
196 List<Feature> list = pm.getFeatures( );
197 list.add( feature );
198 pm.setFeatures( list );
199
200 savePluginModel( pm );
201 }
202
203
204
205
206
207
208
209
210
211
212 public static Feature getFeature( int nPluginId, int nFeatureId )
213 {
214 PluginModel pm = getPluginModel( nPluginId );
215
216 for ( Feature feature : pm.getFeatures( ) )
217 {
218 if ( feature.getId( ) == nFeatureId )
219 {
220 return feature;
221 }
222 }
223
224 return null;
225 }
226
227
228
229
230
231
232
233
234 private static int getMaxFeatureId( PluginModel pm )
235 {
236 int nMax = 0;
237
238 for ( Feature feature : pm.getFeatures( ) )
239 {
240 if ( feature.getId( ) > nMax )
241 {
242 nMax = feature.getId( );
243 }
244 }
245
246 return nMax;
247 }
248
249
250
251
252
253
254
255
256
257 public static void updateFeature( int nPluginId, Feature feature )
258 {
259 PluginModel pm = getPluginModel( nPluginId );
260 List<Feature> list = pm.getFeatures( );
261
262 for ( int i = 0; i < list.size( ); i++ )
263 {
264 Feature f = list.get( i );
265
266 if ( f.getId( ) == feature.getId( ) )
267 {
268 list.set( i, feature );
269 pm.setFeatures( list );
270
271 savePluginModel( pm );
272
273 break;
274 }
275 }
276 }
277
278
279
280
281
282
283
284
285
286 public static void removeFeature( int nPluginId, int nFeatureId )
287 {
288 PluginModel pm = getPluginModel( nPluginId );
289 List<Feature> list = pm.getFeatures( );
290
291 for ( int i = 0; i < list.size( ); i++ )
292 {
293 Feature f = list.get( i );
294
295 if ( f.getId( ) == nFeatureId )
296 {
297 list.remove( i );
298 pm.setFeatures( list );
299
300 savePluginModel( pm );
301
302 break;
303 }
304 }
305 }
306
307
308
309
310
311
312
313
314
315
316
317
318
319 public static Application getApplication( int nPluginId, int nApplicationId )
320 {
321 PluginModel pm = getPluginModel( nPluginId );
322
323 return getApplication( pm, nApplicationId );
324 }
325
326
327
328
329
330
331
332
333
334
335 public static Application getApplication( PluginModel pm, int nApplicationId )
336 {
337 for ( Application application : pm.getApplications( ) )
338 {
339 if ( application.getId( ) == nApplicationId )
340 {
341 return application;
342 }
343 }
344
345 return null;
346 }
347
348
349
350
351
352
353
354
355
356 public static void addApplication( int nPluginId, Application application )
357 {
358 PluginModel pm = getPluginModel( nPluginId );
359 application.setId( getMaxApplicationId( pm ) + 1 );
360 List<Application> list = pm.getApplications( );
361 list.add( application );
362 pm.setApplications( list );
363
364 savePluginModel( pm );
365 }
366
367
368
369
370
371
372
373
374 private static int getMaxApplicationId( PluginModel pm )
375 {
376 int nMax = 0;
377
378 for ( Application application : pm.getApplications( ) )
379 {
380 if ( application.getId( ) > nMax )
381 {
382 nMax = application.getId( );
383 }
384 }
385
386 return nMax;
387 }
388
389
390
391
392
393
394
395
396
397 public static void updateApplication( int nPluginId, Application application )
398 {
399 PluginModel pm = getPluginModel( nPluginId );
400 List<Application> list = pm.getApplications( );
401
402 for ( int i = 0; i < list.size( ); i++ )
403 {
404 Application app = list.get( i );
405
406 if ( app.getId( ) == application.getId( ) )
407 {
408 list.set( i, application );
409 pm.setApplications( list );
410
411 savePluginModel( pm );
412
413 break;
414 }
415 }
416 }
417
418
419
420
421
422
423
424
425
426 public static void removeApplication( int nPluginId, int nApplicationId )
427 {
428 PluginModel pm = getPluginModel( nPluginId );
429 List<Application> list = pm.getApplications( );
430
431 for ( int i = 0; i < list.size( ); i++ )
432 {
433 Application f = list.get( i );
434
435 if ( f.getId( ) == nApplicationId )
436 {
437 list.remove( i );
438 pm.setApplications( list );
439
440 savePluginModel( pm );
441
442 break;
443 }
444 }
445 }
446
447
448
449
450
451
452
453
454
455
456
457
458
459 public static Portlet getPortlet( int nPluginId, int nPortletId )
460 {
461 PluginModel pm = getPluginModel( nPluginId );
462
463 for ( Portlet portlet : pm.getPortlets( ) )
464 {
465 if ( portlet.getId( ) == nPortletId )
466 {
467 return portlet;
468 }
469 }
470
471 return null;
472 }
473
474
475
476
477
478
479
480
481
482 public static void addPortlet( int nPluginId, Portlet portlet )
483 {
484 PluginModel pm = getPluginModel( nPluginId );
485 portlet.setId( getMaxPortletId( pm ) + 1 );
486 List<Portlet> portletList = pm.getPortlets( );
487 portletList.add( portlet );
488 pm.setPortlets( portletList );
489 savePluginModel( pm );
490 }
491
492
493
494
495
496
497
498
499 private static int getMaxPortletId( PluginModel pm )
500 {
501 int nMax = 0;
502
503 for ( Portlet portlet : pm.getPortlets( ) )
504 {
505 if ( portlet.getId( ) > nMax )
506 {
507 nMax = portlet.getId( );
508 }
509 }
510
511 return nMax;
512 }
513
514
515
516
517
518
519
520
521
522 public static void updatePortlet( int nPluginId, Portlet portlet )
523 {
524 PluginModel pm = getPluginModel( nPluginId );
525 List<Portlet> list = pm.getPortlets( );
526
527 for ( int i = 0; i < list.size( ); i++ )
528 {
529 Portlet p = list.get( i );
530
531 if ( p.getId( ) == portlet.getId( ) )
532 {
533 list.set( i, portlet );
534 pm.setPortlets( list );
535
536 savePluginModel( pm );
537
538 break;
539 }
540 }
541 }
542
543
544
545
546
547
548
549
550
551 public static void removePortlet( int nPluginId, int nPortletId )
552 {
553 PluginModel pm = getPluginModel( nPluginId );
554 List<Portlet> list = pm.getPortlets( );
555
556 for ( int i = 0; i < list.size( ); i++ )
557 {
558 Portlet p = list.get( i );
559
560 if ( p.getId( ) == nPortletId )
561 {
562 list.remove( i );
563 pm.setPortlets( list );
564 savePluginModel( pm );
565
566 break;
567 }
568 }
569 }
570
571
572
573
574
575
576
577
578
579
580
581
582 public static BusinessClass getBusinessClass( int nPluginId, int nBusinessClassId )
583 {
584 PluginModel pm = getPluginModel( nPluginId );
585
586 return getBusinessClass( pm, nBusinessClassId );
587 }
588
589
590
591
592
593
594
595
596
597
598 public static BusinessClass getBusinessClass( PluginModel pm, int nBusinessClassId )
599 {
600 for ( BusinessClass bc : pm.getBusinessClasses( ) )
601 {
602 if ( bc.getId( ) == nBusinessClassId )
603 {
604 return bc;
605 }
606 }
607
608 return null;
609 }
610
611
612
613
614
615
616
617
618
619
620 public static BusinessClass addBusinessClass( int nPluginId, BusinessClassFormBean bc )
621 {
622 PluginModel pm = getPluginModel( nPluginId );
623
624 BusinessClass businessClass;
625
626 try
627 {
628 businessClass = _mapper.readValue( _mapper.writeValueAsString( bc ), BusinessClass.class );
629 }
630 catch( IOException e )
631 {
632 throw new AppException( "Mapping exception", e );
633 }
634
635 List<BusinessClass> businessClassesList;
636 businessClass.setId( getMaxBusinessClassId( pm ) + 1 );
637
638 String strBusinessClass = "";
639 char charBusinessClass[] = bc.getBusinessClass( ).toCharArray( );
640 for ( int i = 0; i < charBusinessClass.length; i++ )
641 {
642 if ( Character.isUpperCase( charBusinessClass [i] ) )
643 {
644 strBusinessClass += UNDERSCORE;
645 }
646 strBusinessClass += Character.toLowerCase( charBusinessClass [i] );
647 }
648 businessClass.setPrimaryKey( ID + strBusinessClass );
649
650 businessClassesList = pm.getBusinessClasses( );
651 businessClassesList.add( businessClass );
652 pm.setBusinessClasses( businessClassesList );
653 savePluginModel( pm );
654
655 return businessClass;
656 }
657
658
659
660
661
662
663
664
665 private static int getMaxBusinessClassId( PluginModel pm )
666 {
667 int nMax = 0;
668
669 for ( BusinessClass bc : pm.getBusinessClasses( ) )
670 {
671 if ( bc.getId( ) > nMax )
672 {
673 nMax = bc.getId( );
674 }
675 }
676
677 return nMax;
678 }
679
680
681
682
683
684
685
686
687
688 public static void updateBusinessClass( int nPluginId, BusinessClassFormBean businessClass )
689 {
690 PluginModel pm = getPluginModel( nPluginId );
691 List<BusinessClass> list = pm.getBusinessClasses( );
692
693 for ( int i = 0; i < list.size( ); i++ )
694 {
695 BusinessClass bc = list.get( i );
696
697 if ( bc.getId( ) == businessClass.getId( ) )
698 {
699
700 BusinessClass newBusinessClass = null;
701 List<Attribute> attrList = bc.getAttributes( );
702
703 try
704 {
705 newBusinessClass = _mapper.readValue( _mapper.writeValueAsString( businessClass ), bc.getClass( ) );
706 }
707 catch( IOException e )
708 {
709
710 throw new AppException( "JSON parsing error", e );
711 }
712
713 if ( attrList != null && !attrList.isEmpty( ) )
714 {
715 newBusinessClass.setAttributes( attrList );
716 }
717
718 list.set( i, newBusinessClass );
719 pm.setBusinessClasses( list );
720
721 savePluginModel( pm );
722
723 break;
724 }
725 }
726 }
727
728
729
730
731
732
733
734
735
736 public static void removeBusinessClass( int nPluginId, int nBusinessClassId )
737 {
738 PluginModel pm = getPluginModel( nPluginId );
739 List<BusinessClass> list = pm.getBusinessClasses( );
740
741 for ( int i = 0; i < list.size( ); i++ )
742 {
743 BusinessClass bc = list.get( i );
744
745 if ( bc.getId( ) == nBusinessClassId )
746 {
747 list.remove( i );
748 pm.setBusinessClasses( list );
749 savePluginModel( pm );
750
751 break;
752 }
753 }
754 }
755
756
757
758
759
760
761
762 public static void removeAll( int nPluginId )
763 {
764 PluginModel pm = getPluginModel( nPluginId );
765 pm.getApplications( ).clear( );
766 pm.getBusinessClasses( ).clear( );
767 pm.getFeatures( ).clear( );
768 pm.getPortlets( ).clear( );
769 savePluginModel( pm );
770 }
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785 public static Attribute getAttribute( int nPluginId, int nBusinessClassId, int nAttributeId )
786 {
787 PluginModel pm = getPluginModel( nPluginId );
788 BusinessClass bc = getBusinessClass( pm, nBusinessClassId );
789 if ( bc != null )
790 {
791 List<Attribute> listAttributes = bc.getAttributes( );
792
793 for ( Attribute attribute : listAttributes )
794 {
795 if ( attribute.getId( ) == nAttributeId )
796 {
797 return attribute;
798 }
799 }
800
801 return null;
802 }
803 else
804 {
805 return null;
806 }
807 }
808
809
810
811
812
813
814
815
816
817
818
819 public static void addAttribute( int nPluginId, int nBusinessClassId, Attribute attribute )
820 {
821 PluginModel pm = getPluginModel( nPluginId );
822 BusinessClass bc = getBusinessClass( pm, nBusinessClassId );
823 if ( bc != null )
824 {
825 List<Attribute> listAttributes = bc.getAttributes( );
826 attribute.setId( getMaxAttributeId( listAttributes ) + 1 );
827 attribute.setMaxLength( getAttributeMaxLength( attribute.getAttributeTypeId( ) ) );
828
829 listAttributes.add( attribute );
830 bc.setAttributes( listAttributes );
831
832 savePluginModel( pm );
833 }
834 }
835
836
837
838
839
840
841
842
843 private static int getMaxAttributeId( List<Attribute> listAttributes )
844 {
845 int nMax = 0;
846
847 for ( Attribute attribute : listAttributes )
848 {
849 if ( attribute.getId( ) > nMax )
850 {
851 nMax = attribute.getId( );
852 }
853 }
854
855 return nMax;
856 }
857
858
859
860
861
862
863
864
865
866
867
868 public static void updateAttribute( int nPluginId, int nBusinessClassId, Attribute attribute )
869 {
870 PluginModel pm = getPluginModel( nPluginId );
871 BusinessClass bc = getBusinessClass( pm, nBusinessClassId );
872 if ( bc != null )
873 {
874 List<Attribute> list = bc.getAttributes( );
875
876 for ( int i = 0; i < list.size( ); i++ )
877 {
878 Attribute attr = list.get( i );
879
880 if ( attr.getId( ) == attribute.getId( ) )
881 {
882 list.set( i, attribute );
883 bc.setAttributes( list );
884 savePluginModel( pm );
885
886 break;
887 }
888 }
889 }
890 }
891
892
893
894
895
896
897
898
899
900
901
902 public static void removeAttribute( int nPluginId, int nBusinessClassId, int nAttributeId )
903 {
904 PluginModel pm = getPluginModel( nPluginId );
905 BusinessClass bc = getBusinessClass( pm, nBusinessClassId );
906 List<Attribute> list;
907 if ( bc != null )
908 {
909 list = bc.getAttributes( );
910 for ( int i = 0; i < list.size( ); i++ )
911 {
912 Attribute attr = list.get( i );
913
914 if ( attr.getId( ) == nAttributeId )
915 {
916 list.remove( i );
917 bc.setAttributes( list );
918 savePluginModel( pm );
919
920 break;
921 }
922 }
923 }
924
925 }
926
927
928
929
930
931
932
933
934
935
936
937 public static void addRest( int nPluginId, Rest rest )
938 {
939 PluginModel pm = getPluginModel( nPluginId );
940 pm.setRest( rest );
941 savePluginModel( pm );
942 }
943
944
945
946
947
948
949
950
951 public static Rest getRest( int nPluginId )
952 {
953 PluginModel pm = getPluginModel( nPluginId );
954 return pm.getRest( );
955 }
956
957
958
959
960
961
962
963
964
965 public static void updateRest( int nPluginId, Rest rest )
966 {
967 PluginModel pm = getPluginModel( nPluginId );
968 pm.setRest( rest );
969 savePluginModel( pm );
970 }
971
972
973
974
975
976
977
978
979 public static List<BusinessClass> getBusinessClassesByRest( PluginModel pm )
980 {
981 List<BusinessClass> list = new ArrayList<>( );
982 List<BusinessClass> listAll = pm.getBusinessClasses( );
983 Rest rest = pm.getRest( );
984
985 for ( int i : rest.getIdBusinessClasses( ) )
986 {
987 for ( BusinessClass bc : listAll )
988 {
989 if ( bc.getId( ) == i )
990 {
991 list.add( bc );
992 }
993 }
994 }
995 return list;
996 }
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007 public static List<BusinessClass> getBusinessClassesByApplication( PluginModel pm, int nApplicationId )
1008 {
1009 List<BusinessClass> list = new ArrayList<>( );
1010 List<Application> listAll = pm.getApplications( );
1011 List<BusinessClass> listAll2 = pm.getBusinessClasses( );
1012
1013 for ( Application a : listAll )
1014 {
1015 if ( a.getId( ) == nApplicationId )
1016 {
1017 for ( int i : a.getIdBusinessClasses( ) )
1018 {
1019 for ( BusinessClass bc : listAll2 )
1020 {
1021 if ( bc.getId( ) == i )
1022 {
1023 list.add( bc );
1024 }
1025 }
1026 }
1027 }
1028 }
1029 return list;
1030 }
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041 public static List<BusinessClass> getBusinessClassesByFeature( PluginModel pm, int nFeatureId )
1042 {
1043 List<BusinessClass> list = new ArrayList<>( );
1044 List<Feature> listAll = pm.getFeatures( );
1045 List<BusinessClass> listAll2 = pm.getBusinessClasses( );
1046
1047 for ( Feature f : listAll )
1048 {
1049 if ( f.getId( ) == nFeatureId )
1050 {
1051 for ( int i : f.getIdBusinessClasses( ) )
1052 {
1053 for ( BusinessClass bc : listAll2 )
1054 {
1055 if ( bc.getId( ) == i )
1056 {
1057 list.add( bc );
1058 }
1059 }
1060 }
1061 }
1062 }
1063 return list;
1064 }
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075 public static Feature getFeatureByBusinessClass( PluginModel pm, int nBusinessClassId )
1076 {
1077 Featurepluginwizard/business/model/Feature.html#Feature">Feature feature = new Feature( );
1078 List<Feature> listAll = pm.getFeatures( );
1079 List<BusinessClass> listAll2 = pm.getBusinessClasses( );
1080
1081 for ( Feature f : listAll )
1082 {
1083 for ( int i : f.getIdBusinessClasses( ) )
1084 {
1085 if ( i == nBusinessClassId )
1086 {
1087 for ( BusinessClass bc : listAll2 )
1088 {
1089 if ( bc.getId( ) == i )
1090 {
1091 feature = f;
1092 }
1093 }
1094 }
1095 }
1096 }
1097
1098 return feature;
1099 }
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110 public static Application getApplicationByBusinessClass( PluginModel pm, int nBusinessClassId )
1111 {
1112 Applicationzard/business/model/Application.html#Application">Application application = new Application( );
1113 List<Application> listAll = pm.getApplications( );
1114 List<BusinessClass> listAll2 = pm.getBusinessClasses( );
1115
1116 for ( Application a : listAll )
1117 {
1118 for ( int i : a.getIdBusinessClasses( ) )
1119 {
1120 if ( i == nBusinessClassId )
1121 {
1122 for ( BusinessClass bc : listAll2 )
1123 {
1124 if ( bc.getId( ) == i )
1125 {
1126 application = a;
1127 }
1128 }
1129 }
1130 }
1131 }
1132
1133 return application;
1134 }
1135
1136
1137
1138
1139
1140
1141
1142 public static ReferenceList getComboBusinessClasses( int nPluginId )
1143 {
1144 ReferenceList list = new ReferenceList( );
1145
1146 for ( BusinessClass bc : getPluginModel( nPluginId ).getBusinessClasses( ) )
1147 {
1148 list.addItem( bc.getId( ), bc.getBusinessClass( ) );
1149 }
1150
1151 return list;
1152 }
1153
1154
1155
1156
1157
1158
1159 public static ReferenceList getAttributeTypes( Locale locale )
1160 {
1161 return _serviceAttribute.getAttributeTypes( locale );
1162 }
1163
1164
1165
1166
1167
1168
1169
1170
1171 public static String getAttributeType( int nAttributeTypeId )
1172 {
1173 AttributeType type = _serviceAttribute.getType( nAttributeTypeId );
1174
1175 return type.getJavaType( );
1176 }
1177
1178
1179
1180
1181
1182
1183
1184
1185 private static int getAttributeMaxLength( int nAttributeTypeId )
1186 {
1187 AttributeType type = _serviceAttribute.getType( nAttributeTypeId );
1188
1189 return type.getMaxLength( );
1190 }
1191
1192
1193
1194
1195
1196
1197
1198
1199 public static String getAttributePrefix( int nAttributeTypeId )
1200 {
1201 return _serviceAttribute.getType( nAttributeTypeId ).getPrefix( );
1202 }
1203
1204
1205
1206
1207
1208
1209
1210
1211 public static String getAttributeConstraint( int nAttributeTypeId )
1212 {
1213 return _serviceAttribute.getType( nAttributeTypeId ).getConstraint( );
1214 }
1215
1216
1217
1218
1219
1220
1221
1222
1223 public static String getAttributeTypeDescription( int nAttributeTypeId )
1224 {
1225 return _serviceAttribute.getType( nAttributeTypeId ).getDescription( );
1226 }
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236 public static void updateDescription( int nPluginId, DescriptionFormBean description )
1237 {
1238 PluginModel pm = getPluginModel( nPluginId );
1239
1240 try
1241 {
1242 BeanUtils.copyProperties( pm, description );
1243 }
1244 catch( IllegalAccessException | InvocationTargetException e )
1245 {
1246 throw new AppException( "Bean exception", e );
1247 }
1248
1249 savePluginModel( pm );
1250 }
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260 public static DescriptionFormBean getDescription( int nPluginId )
1261 {
1262 PluginModel pm = getPluginModel( nPluginId );
1263
1264 try
1265 {
1266 return _mapper.readValue( _mapper.writeValueAsString( pm ), DescriptionFormBean.class );
1267 }
1268 catch( IOException e )
1269 {
1270 throw new AppException( "JSON exception", e );
1271
1272 }
1273 }
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283 public static BusinessClassFormBean getFormBusinessClass( int nPluginId, int nBusinessClassId )
1284 {
1285 PluginModel pm = getPluginModel( nPluginId );
1286
1287 try
1288 {
1289 return _mapper.readValue( _mapper.writeValueAsString( getBusinessClass( pm, nBusinessClassId ) ), BusinessClassFormBean.class );
1290 }
1291 catch( IOException e )
1292 {
1293 throw new AppException( "JSON exception", e );
1294 }
1295 }
1296
1297
1298
1299
1300
1301
1302
1303
1304 public static void updateConfiguration( int nPluginId, ConfigurationFormBean configuration )
1305 {
1306 PluginModel pm = getPluginModel( nPluginId );
1307
1308 try
1309 {
1310 BeanUtils.copyProperties( pm.getConfiguration( ), configuration );
1311 }
1312 catch( IllegalAccessException | InvocationTargetException e )
1313 {
1314 throw new AppException( "Bean exception", e );
1315 }
1316
1317 savePluginModel( pm );
1318 }
1319
1320 }