18
18
import com .magento .idea .magento2plugin .actions .generation .data .DataModelData ;
19
19
import com .magento .idea .magento2plugin .actions .generation .data .DataModelInterfaceData ;
20
20
import com .magento .idea .magento2plugin .actions .generation .data .DbSchemaXmlData ;
21
+ import com .magento .idea .magento2plugin .actions .generation .data .EntityDataMapperData ;
22
+ import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
21
23
import com .magento .idea .magento2plugin .actions .generation .data .LayoutXmlData ;
22
24
import com .magento .idea .magento2plugin .actions .generation .data .MenuXmlData ;
23
25
import com .magento .idea .magento2plugin .actions .generation .data .ModelData ;
24
- import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
25
26
import com .magento .idea .magento2plugin .actions .generation .data .PreferenceDiXmFileData ;
26
27
import com .magento .idea .magento2plugin .actions .generation .data .ResourceModelData ;
27
28
import com .magento .idea .magento2plugin .actions .generation .data .RoutesXmlData ;
39
40
import com .magento .idea .magento2plugin .actions .generation .generator .DataModelInterfaceGenerator ;
40
41
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaWhitelistJsonGenerator ;
41
42
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaXmlGenerator ;
43
+ import com .magento .idea .magento2plugin .actions .generation .generator .EntityDataMapperGenerator ;
44
+ import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
42
45
import com .magento .idea .magento2plugin .actions .generation .generator .LayoutXmlGenerator ;
43
46
import com .magento .idea .magento2plugin .actions .generation .generator .MenuXmlGenerator ;
44
47
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleCollectionGenerator ;
45
48
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleControllerClassGenerator ;
46
49
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleModelGenerator ;
47
50
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleResourceModelGenerator ;
48
- import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
49
51
import com .magento .idea .magento2plugin .actions .generation .generator .PreferenceDiXmlGenerator ;
50
52
import com .magento .idea .magento2plugin .actions .generation .generator .RoutesXmlGenerator ;
51
53
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentDataProviderGenerator ;
56
58
import com .magento .idea .magento2plugin .magento .files .ControllerBackendPhp ;
57
59
import com .magento .idea .magento2plugin .magento .files .DataModel ;
58
60
import com .magento .idea .magento2plugin .magento .files .DataModelInterface ;
61
+ import com .magento .idea .magento2plugin .magento .files .EntityDataMapperFile ;
59
62
import com .magento .idea .magento2plugin .magento .files .ModelPhp ;
60
63
import com .magento .idea .magento2plugin .magento .files .ModuleMenuXml ;
61
64
import com .magento .idea .magento2plugin .magento .files .ResourceModelPhp ;
107
110
"PMD.ExcessiveImports" ,
108
111
"PMD.GodClass" ,
109
112
"PMD.TooManyMethods" ,
110
- "PMD.CyclomaticComplexity"
113
+ "PMD.CyclomaticComplexity" ,
114
+ "PMD.ExcessiveClassLength" ,
111
115
})
112
116
public class NewEntityDialog extends AbstractDialog {
113
117
@ NotNull
@@ -280,6 +284,7 @@ private void onOK() {
280
284
generateRoutesXmlFile ();
281
285
generateViewControllerFile ();
282
286
generateSubmitControllerFile ();
287
+ generateEntityDataMapperFile ();
283
288
generateModelGetListQueryFile ();
284
289
generateDataProviderFile ();
285
290
generateLayoutFile ();
@@ -1009,6 +1014,41 @@ private void generateWhitelistJsonFile(final @NotNull DbSchemaXmlData dbSchemaXm
1009
1014
).generate (ACTION_NAME , false );
1010
1015
}
1011
1016
1017
+ /**
1018
+ * Generate entity data mapper type.
1019
+ */
1020
+ private void generateEntityDataMapperFile () {
1021
+ final EntityDataMapperFile entityDataMapperFile =
1022
+ EntityDataMapperFile .getInstance (getEntityName ());
1023
+
1024
+ final String namespace = entityDataMapperFile .getNamespace (getModuleName ());
1025
+ final String classFqn = entityDataMapperFile .getClassFqn (getModuleName ());
1026
+
1027
+ final NamespaceBuilder modelNamespace = getModelNamespace ();
1028
+ final NamespaceBuilder dtoModelNamespace = getDataModelNamespace ();
1029
+ final NamespaceBuilder dtoInterfaceModelNamespace = getDataModelInterfaceNamespace ();
1030
+
1031
+ final String dtoType ;
1032
+
1033
+ if (createInterface .isSelected ()) {
1034
+ dtoType = dtoInterfaceModelNamespace .getClassFqn ();
1035
+ } else {
1036
+ dtoType = dtoModelNamespace .getClassFqn ();
1037
+ }
1038
+
1039
+ new EntityDataMapperGenerator (
1040
+ new EntityDataMapperData (
1041
+ getModuleName (),
1042
+ getEntityName (),
1043
+ namespace ,
1044
+ classFqn ,
1045
+ modelNamespace .getClassFqn (),
1046
+ dtoType
1047
+ ),
1048
+ project
1049
+ ).generate (ACTION_NAME , false );
1050
+ }
1051
+
1012
1052
/**
1013
1053
* Run GetListQuery.php file generator.
1014
1054
*/
@@ -1032,8 +1072,10 @@ private void generateModelGetListQueryFile() {
1032
1072
* @return String
1033
1073
*/
1034
1074
private String getEntityDataMapperType () {
1035
- // TODO: implement with entity data mapper generation.
1036
- return "Test\\ Test\\ Mapper\\ " + getEntityName () + "DataMapper" ;
1075
+ final EntityDataMapperFile entityDataMapperFile =
1076
+ EntityDataMapperFile .getInstance (getEntityName ());
1077
+
1078
+ return entityDataMapperFile .getClassFqn (getModuleName ());
1037
1079
}
1038
1080
1039
1081
/**
0 commit comments