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 .GetListQueryModelData ;
21
22
import com .magento .idea .magento2plugin .actions .generation .data .LayoutXmlData ;
22
23
import com .magento .idea .magento2plugin .actions .generation .data .MenuXmlData ;
23
24
import com .magento .idea .magento2plugin .actions .generation .data .ModelData ;
24
- import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
25
25
import com .magento .idea .magento2plugin .actions .generation .data .PreferenceDiXmFileData ;
26
26
import com .magento .idea .magento2plugin .actions .generation .data .ResourceModelData ;
27
27
import com .magento .idea .magento2plugin .actions .generation .data .RoutesXmlData ;
28
+ import com .magento .idea .magento2plugin .actions .generation .data .SaveEntityControllerFileData ;
28
29
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentDataProviderData ;
29
30
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormButtonData ;
30
31
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormFieldData ;
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 .GetListQueryModelGenerator ;
42
44
import com .magento .idea .magento2plugin .actions .generation .generator .LayoutXmlGenerator ;
43
45
import com .magento .idea .magento2plugin .actions .generation .generator .MenuXmlGenerator ;
44
46
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleCollectionGenerator ;
45
47
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleControllerClassGenerator ;
46
48
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleModelGenerator ;
47
49
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleResourceModelGenerator ;
48
- import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
49
50
import com .magento .idea .magento2plugin .actions .generation .generator .PreferenceDiXmlGenerator ;
50
51
import com .magento .idea .magento2plugin .actions .generation .generator .RoutesXmlGenerator ;
52
+ import com .magento .idea .magento2plugin .actions .generation .generator .SaveEntityControllerFileGenerator ;
51
53
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentDataProviderGenerator ;
52
54
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentFormGenerator ;
53
55
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentGridXmlGenerator ;
60
62
import com .magento .idea .magento2plugin .magento .files .ModuleMenuXml ;
61
63
import com .magento .idea .magento2plugin .magento .files .ResourceModelPhp ;
62
64
import com .magento .idea .magento2plugin .magento .files .UiComponentDataProviderPhp ;
65
+ import com .magento .idea .magento2plugin .magento .files .actions .SaveActionFile ;
63
66
import com .magento .idea .magento2plugin .magento .packages .Areas ;
64
67
import com .magento .idea .magento2plugin .magento .packages .File ;
65
68
import com .magento .idea .magento2plugin .magento .packages .HttpMethod ;
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
@@ -279,7 +283,7 @@ private void onOK() {
279
283
280
284
generateRoutesXmlFile ();
281
285
generateViewControllerFile ();
282
- generateSubmitControllerFile ();
286
+ generateSaveControllerFile ();
283
287
generateModelGetListQueryFile ();
284
288
generateDataProviderFile ();
285
289
generateLayoutFile ();
@@ -303,6 +307,49 @@ private void onOK() {
303
307
this .setVisible (false );
304
308
}
305
309
310
+ /**
311
+ * Generate Save Controller file.
312
+ */
313
+ private void generateSaveControllerFile () {
314
+ final NamespaceBuilder dtoModelNamespace = getDataModelNamespace ();
315
+ final NamespaceBuilder dtoInterfaceModelNamespace = getDataModelInterfaceNamespace ();
316
+ final NamespaceBuilder namespace = new NamespaceBuilder (
317
+ getModuleName (),
318
+ SaveActionFile .CLASS_NAME ,
319
+ SaveActionFile .getDirectory (getEntityName ())
320
+ );
321
+ final String dtoType ;
322
+
323
+ if (createInterface .isSelected ()) {
324
+ dtoType = dtoInterfaceModelNamespace .getClassFqn ();
325
+ } else {
326
+ dtoType = dtoModelNamespace .getClassFqn ();
327
+ }
328
+
329
+ new SaveEntityControllerFileGenerator (new SaveEntityControllerFileData (
330
+ getEntityName (),
331
+ getModuleName (),
332
+ namespace .getNamespace (),
333
+ getSaveEntityCommandClassFqn (),
334
+ dtoType ,
335
+ getAcl (),
336
+ getEntityIdColumn ()
337
+ ), project ).generate (ACTION_NAME , false );
338
+ }
339
+
340
+ /**
341
+ * Get save entity command class Fqn.
342
+ *
343
+ * @return String
344
+ */
345
+ private String getSaveEntityCommandClassFqn () {
346
+ //TODO: change this stub after the save command generated will be implemented.
347
+ final NamespaceBuilder namespaceBuilder =
348
+ new NamespaceBuilder (getModuleName (), "SaveCommand" , "Command/" + getEntityName ());
349
+
350
+ return namespaceBuilder .getClassFqn ();
351
+ }
352
+
306
353
private PsiFile generateModelFile () {
307
354
final NamespaceBuilder modelNamespace = getModelNamespace ();
308
355
final NamespaceBuilder resourceModelNamespace = getResourceModelNamespace ();
@@ -574,24 +621,11 @@ private String getControllerDirectory() {
574
621
return ControllerBackendPhp .DEFAULT_DIR + File .separator ;
575
622
}
576
623
577
- private PsiFile generateSubmitControllerFile () {
578
- final NamespaceBuilder namespace = new NamespaceBuilder (
579
- getModuleName (),
580
- getSubmitActionName (),
581
- getViewControllerDirectory ()
582
- );
583
- return new ModuleControllerClassGenerator (new ControllerFileData (
584
- getViewControllerDirectory (),
585
- getSubmitActionName (),
586
- getModuleName (),
587
- Areas .adminhtml .toString (),
588
- HttpMethod .POST .toString (),
589
- getAcl (),
590
- true ,
591
- namespace .getNamespace ()
592
- ), project ).generate (ACTION_NAME , false );
593
- }
594
-
624
+ /**
625
+ * Get Acl id.
626
+ *
627
+ * @return String
628
+ */
595
629
public String getAcl () {
596
630
return acl .getText ().trim ();
597
631
}
0 commit comments