Skip to content

Commit 994c3b3

Browse files
authored
Merge pull request #597 from bohdan-harniuk/entity-web-api-generation
Entity Web API generation
2 parents d33256d + 4202bbf commit 994c3b3

File tree

42 files changed

+639
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+639
-76
lines changed

resources/fileTemplates/internal/Magento Entity Delete Controller Class.php.ft

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ${CLASS_NAME} extends ${EXTENDS} implements ${IMPLEMENTS_POST}, ${IMPLEMEN
2727

2828
/**
2929
* @param Context $context
30-
* @param DeleteByIdCommand $deleteByIdCommand
30+
* @param ${DELETE_COMMAND} $deleteByIdCommand
3131
*/
3232
public function __construct(
3333
${CONTEXT} $context,

src/com/magento/idea/magento2plugin/actions/generation/data/DeleteEntityByIdCommandData.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class DeleteEntityByIdCommandData {
1414
private final String entityId;
1515
private final String modelName;
1616
private final String resourceModelName;
17+
private final String aclResource;
1718

1819
/**
1920
* Delete Command DTO Constructor.
@@ -23,19 +24,22 @@ public class DeleteEntityByIdCommandData {
2324
* @param entityId String
2425
* @param modelName String
2526
* @param resourceModelName String
27+
* @param aclResource String
2628
*/
2729
public DeleteEntityByIdCommandData(
2830
final @NotNull String moduleName,
2931
final @NotNull String entityName,
3032
final @NotNull String entityId,
3133
final @NotNull String modelName,
32-
final @NotNull String resourceModelName
34+
final @NotNull String resourceModelName,
35+
final @NotNull String aclResource
3336
) {
3437
this.moduleName = moduleName;
3538
this.entityName = entityName;
3639
this.entityId = entityId;
3740
this.modelName = modelName;
3841
this.resourceModelName = resourceModelName;
42+
this.aclResource = aclResource;
3943
}
4044

4145
/**
@@ -82,4 +86,13 @@ public String getModelName() {
8286
public String getResourceModelName() {
8387
return resourceModelName;
8488
}
89+
90+
/**
91+
* Get ACL resource.
92+
*
93+
* @return String
94+
*/
95+
public String getAclResource() {
96+
return aclResource;
97+
}
8598
}

src/com/magento/idea/magento2plugin/actions/generation/data/DeleteEntityControllerFileData.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class DeleteEntityControllerFileData {
1313
private final String moduleName;
1414
private final String acl;
1515
private final String entityId;
16+
private final boolean hasDeleteCommandInterface;
1617

1718
/**
1819
* Controller Delete file constructor.
@@ -21,17 +22,20 @@ public class DeleteEntityControllerFileData {
2122
* @param moduleName String
2223
* @param acl String
2324
* @param entityId String
25+
* @param hasDeleteCommandInterface boolean
2426
*/
2527
public DeleteEntityControllerFileData(
2628
final @NotNull String entityName,
2729
final @NotNull String moduleName,
2830
final @NotNull String acl,
29-
final @NotNull String entityId
31+
final @NotNull String entityId,
32+
final boolean hasDeleteCommandInterface
3033
) {
3134
this.entityName = entityName;
3235
this.moduleName = moduleName;
3336
this.acl = acl;
3437
this.entityId = entityId;
38+
this.hasDeleteCommandInterface = hasDeleteCommandInterface;
3539
}
3640

3741
/**
@@ -69,4 +73,13 @@ public String getAcl() {
6973
public String getEntityId() {
7074
return entityId;
7175
}
76+
77+
/**
78+
* Check if delete command has Web API interface.
79+
*
80+
* @return boolean
81+
*/
82+
public boolean isHasDeleteCommandInterface() {
83+
return hasDeleteCommandInterface;
84+
}
7285
}

src/com/magento/idea/magento2plugin/actions/generation/data/EntityDataMapperData.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class EntityDataMapperData {
1515
private final String modelName;
1616
private final String dtoName;
1717
private final String dtoInterfaceName;
18-
private final boolean dtoWithInterface;
18+
private final boolean hasDtoInterface;
1919

2020
/**
2121
* Magento entity data mapper data constructor.
@@ -25,22 +25,22 @@ public class EntityDataMapperData {
2525
* @param modelName String
2626
* @param dtoName String
2727
* @param dtoInterfaceName String
28-
* @param isDtoWithInterface boolean
28+
* @param hasDtoInterface boolean
2929
*/
3030
public EntityDataMapperData(
3131
final @NotNull String moduleName,
3232
final @NotNull String entityName,
3333
final @NotNull String modelName,
3434
final @NotNull String dtoName,
3535
final @NotNull String dtoInterfaceName,
36-
final boolean isDtoWithInterface
36+
final boolean hasDtoInterface
3737
) {
3838
this.moduleName = moduleName;
3939
this.entityName = entityName;
4040
this.modelName = modelName;
4141
this.dtoName = dtoName;
4242
this.dtoInterfaceName = dtoInterfaceName;
43-
this.dtoWithInterface = isDtoWithInterface;
43+
this.hasDtoInterface = hasDtoInterface;
4444
}
4545

4646
/**
@@ -93,7 +93,7 @@ public String getDtoInterfaceName() {
9393
*
9494
* @return boolean
9595
*/
96-
public boolean isDtoWithInterface() {
97-
return dtoWithInterface;
96+
public boolean isHasDtoInterface() {
97+
return hasDtoInterface;
9898
}
9999
}

src/com/magento/idea/magento2plugin/actions/generation/data/GetListQueryModelData.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class GetListQueryModelData {
1313
private final String entityName;
1414
private final String modelName;
1515
private final String collectionName;
16+
private final String aclResource;
1617

1718
/**
1819
* Query Model DTO Constructor.
@@ -21,17 +22,20 @@ public class GetListQueryModelData {
2122
* @param entityName String
2223
* @param modelName String
2324
* @param collectionName String
25+
* @param aclResource String
2426
*/
2527
public GetListQueryModelData(
2628
final @NotNull String moduleName,
2729
final @NotNull String entityName,
2830
final @NotNull String modelName,
29-
final @NotNull String collectionName
31+
final @NotNull String collectionName,
32+
final @NotNull String aclResource
3033
) {
3134
this.moduleName = moduleName;
3235
this.entityName = entityName;
3336
this.modelName = modelName;
3437
this.collectionName = collectionName;
38+
this.aclResource = aclResource;
3539
}
3640

3741
/**
@@ -69,4 +73,13 @@ public String getModelName() {
6973
public String getCollectionName() {
7074
return collectionName;
7175
}
76+
77+
/**
78+
* Get entity acl resource.
79+
*
80+
* @return String
81+
*/
82+
public String getAclResource() {
83+
return aclResource;
84+
}
7285
}

src/com/magento/idea/magento2plugin/actions/generation/data/SaveEntityCommandData.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SaveEntityCommandData {
1616
private final String dtoName;
1717
private final String dtoInterfaceName;
1818
private final boolean dtoWithInterface;
19+
private final String aclResource;
1920

2021
/**
2122
* Save Command DTO Constructor.
@@ -27,6 +28,7 @@ public class SaveEntityCommandData {
2728
* @param dtoName String
2829
* @param dtoInterfaceName String
2930
* @param isDtoWithInterface boolean
31+
* @param aclResource String
3032
*/
3133
public SaveEntityCommandData(
3234
final @NotNull String moduleName,
@@ -35,7 +37,8 @@ public SaveEntityCommandData(
3537
final @NotNull String resourceModelName,
3638
final @NotNull String dtoName,
3739
final @NotNull String dtoInterfaceName,
38-
final boolean isDtoWithInterface
40+
final boolean isDtoWithInterface,
41+
final @NotNull String aclResource
3942
) {
4043
this.moduleName = moduleName;
4144
this.entityName = entityName;
@@ -44,6 +47,7 @@ public SaveEntityCommandData(
4447
this.dtoName = dtoName;
4548
this.dtoInterfaceName = dtoInterfaceName;
4649
this.dtoWithInterface = isDtoWithInterface;
50+
this.aclResource = aclResource;
4751
}
4852

4953
/**
@@ -108,4 +112,13 @@ public String getDtoInterfaceName() {
108112
public boolean isDtoWithInterface() {
109113
return dtoWithInterface;
110114
}
115+
116+
/**
117+
* Get ACL resource.
118+
*
119+
* @return String
120+
*/
121+
public String getAclResource() {
122+
return aclResource;
123+
}
111124
}

src/com/magento/idea/magento2plugin/actions/generation/data/SaveEntityControllerFileData.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class SaveEntityControllerFileData {
1515
private final String entityId;
1616
private final String dtoName;
1717
private final String dtoInterfaceName;
18-
private final boolean dtoWithInterface;
18+
private final boolean hasDtoInterface;
19+
private final boolean hasSaveCommandInterface;
1920

2021
/**
2122
* Controller save file constructor.
@@ -26,7 +27,8 @@ public class SaveEntityControllerFileData {
2627
* @param entityId String
2728
* @param dtoName String
2829
* @param dtoInterfaceName String
29-
* @param isDtoWithInterface boolean
30+
* @param hasDtoInterface boolean
31+
* @param hasSaveCommandInterface boolean
3032
*/
3133
public SaveEntityControllerFileData(
3234
final @NotNull String entityName,
@@ -35,15 +37,17 @@ public SaveEntityControllerFileData(
3537
final @NotNull String entityId,
3638
final @NotNull String dtoName,
3739
final @NotNull String dtoInterfaceName,
38-
final boolean isDtoWithInterface
40+
final boolean hasDtoInterface,
41+
final boolean hasSaveCommandInterface
3942
) {
4043
this.entityName = entityName;
4144
this.moduleName = moduleName;
4245
this.acl = acl;
4346
this.entityId = entityId;
4447
this.dtoName = dtoName;
4548
this.dtoInterfaceName = dtoInterfaceName;
46-
this.dtoWithInterface = isDtoWithInterface;
49+
this.hasDtoInterface = hasDtoInterface;
50+
this.hasSaveCommandInterface = hasSaveCommandInterface;
4751
}
4852

4953
/**
@@ -105,7 +109,16 @@ public String getDtoInterfaceName() {
105109
*
106110
* @return boolean
107111
*/
108-
public boolean isDtoWithInterface() {
109-
return dtoWithInterface;
112+
public boolean isHasDtoInterface() {
113+
return hasDtoInterface;
114+
}
115+
116+
/**
117+
* Check if save command has interface.
118+
*
119+
* @return boolean
120+
*/
121+
public boolean isHasSaveCommandInterface() {
122+
return hasSaveCommandInterface;
110123
}
111124
}

src/com/magento/idea/magento2plugin/actions/generation/data/UiComponentDataProviderData.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class UiComponentDataProviderData {
1111
private final String path;
1212
private final String entityName;
1313
private final String entityIdFieldName;
14+
private final boolean hasQueryInterface;
1415

1516
/**
1617
* UiComponentGridDataProviderData constructor.
@@ -22,7 +23,7 @@ public UiComponentDataProviderData(
2223
final String name,
2324
final String path
2425
) {
25-
this(name, path, null, null);
26+
this(name, path, null, null, false);
2627
}
2728

2829
/**
@@ -32,17 +33,20 @@ public UiComponentDataProviderData(
3233
* @param path String
3334
* @param entityName String
3435
* @param entityIdFieldName String
36+
* @param hasQueryInterface boolean
3537
*/
3638
public UiComponentDataProviderData(
3739
final String name,
3840
final String path,
3941
final String entityName,
40-
final String entityIdFieldName
42+
final String entityIdFieldName,
43+
final boolean hasQueryInterface
4144
) {
4245
this.name = name;
4346
this.path = path;
4447
this.entityName = entityName;
4548
this.entityIdFieldName = entityIdFieldName;
49+
this.hasQueryInterface = hasQueryInterface;
4650
}
4751

4852
/**
@@ -80,4 +84,13 @@ public String getEntityName() {
8084
public String getEntityIdFieldName() {
8185
return entityIdFieldName;
8286
}
87+
88+
/**
89+
* Check if query service has Web API interface.
90+
*
91+
* @return boolean
92+
*/
93+
public boolean isHasQueryInterface() {
94+
return hasQueryInterface;
95+
}
8396
}

src/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/DataProviderDtoConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public DataProviderDtoConverter(
3030
newEntityDialogData.getEntityName().concat("DataProvider"),
3131
UiComponentDataProviderFile.DIRECTORY,
3232
newEntityDialogData.getEntityName(),
33-
newEntityDialogData.getIdFieldName()
33+
newEntityDialogData.getIdFieldName(),
34+
newEntityDialogData.hasWebApi()
3435
);
3536
}
3637
}

src/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/DeleteEntityByIdCommandDtoConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public DeleteEntityByIdCommandDtoConverter(
2929
newEntityDialogData.getEntityName(),
3030
newEntityDialogData.getIdFieldName(),
3131
newEntityDialogData.getEntityName().concat("Model"),
32-
newEntityDialogData.getEntityName().concat("Resource")
32+
newEntityDialogData.getEntityName().concat("Resource"),
33+
newEntityDialogData.getAclId()
3334
);
3435
}
3536
}

0 commit comments

Comments
 (0)