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