Skip to content

Commit d04537a

Browse files
committed
Added data models for queue generator
1 parent c458c06 commit d04537a

File tree

5 files changed

+237
-12
lines changed

5 files changed

+237
-12
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
public class QueueCommunicationData {
4+
private String topicName;
5+
private String handlerName;
6+
private String handlerType;
7+
private String handlerMethod;
8+
9+
public QueueCommunicationData(
10+
String topicName,
11+
String handlerName,
12+
String handlerType,
13+
String handlerMethod
14+
) {
15+
this.topicName = topicName;
16+
this.handlerName = handlerName;
17+
this.handlerType = handlerType;
18+
this.handlerMethod = handlerMethod;
19+
}
20+
21+
public String getTopicName() {
22+
return topicName;
23+
}
24+
25+
public String getHandlerName() {
26+
return handlerName;
27+
}
28+
29+
public String getHandlerType() {
30+
return handlerType;
31+
}
32+
33+
public String getHandlerMethod() {
34+
return handlerMethod;
35+
}
36+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
public class QueueConsumerData {
4+
private String consumerName;
5+
private String queueName;
6+
private String consumerType;
7+
private String maxMessages;
8+
private String connectionName;
9+
10+
public QueueConsumerData(
11+
String consumerName,
12+
String queueName,
13+
String consumerType,
14+
String maxMessages,
15+
String connectionName
16+
) {
17+
this.consumerName = consumerName;
18+
this.queueName = queueName;
19+
this.consumerType = consumerType;
20+
this.maxMessages = maxMessages;
21+
this.connectionName = connectionName;
22+
}
23+
24+
public String getConsumerName() {
25+
return consumerName;
26+
}
27+
28+
public String getQueueName() {
29+
return queueName;
30+
}
31+
32+
public String getConsumerType() {
33+
return consumerType;
34+
}
35+
36+
public String getMaxMessages() {
37+
return maxMessages;
38+
}
39+
40+
public String getConnectionName() {
41+
return connectionName;
42+
}
43+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
public class QueuePublisherData {
4+
private String topicName;
5+
private String connectionName;
6+
private String exchangeName;
7+
8+
public QueuePublisherData(String topicName, String connectionName, String exchangeName) {
9+
this.topicName = topicName;
10+
this.connectionName = connectionName;
11+
this.exchangeName = exchangeName;
12+
}
13+
14+
public String getTopicName() {
15+
return topicName;
16+
}
17+
18+
public String getConnectionName() {
19+
return connectionName;
20+
}
21+
22+
public String getExchangeName() {
23+
return exchangeName;
24+
}
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
public class QueueTopologyData {
4+
private String exchangeName;
5+
private String bindingId;
6+
private String bindingTopic;
7+
private String bindingQueue;
8+
9+
public QueueTopologyData(String exchangeName, String bindingId, String bindingTopic, String bindingQueue) {
10+
this.exchangeName = exchangeName;
11+
this.bindingId = bindingId;
12+
this.bindingTopic = bindingTopic;
13+
this.bindingQueue = bindingQueue;
14+
}
15+
16+
public String getExchangeName() {
17+
return exchangeName;
18+
}
19+
20+
public String getBindingId() {
21+
return bindingId;
22+
}
23+
24+
public String getBindingTopic() {
25+
return bindingTopic;
26+
}
27+
28+
public String getBindingQueue() {
29+
return bindingQueue;
30+
}
31+
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewMessageQueueDialog.java

Lines changed: 102 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import com.intellij.openapi.project.Project;
44
import com.intellij.psi.PsiDirectory;
55
import com.magento.idea.magento2plugin.actions.generation.NewDataModelAction;
6+
import com.magento.idea.magento2plugin.actions.generation.NewMessageQueueAction;
7+
import com.magento.idea.magento2plugin.actions.generation.data.QueueCommunicationData;
8+
import com.magento.idea.magento2plugin.actions.generation.data.QueueConsumerData;
9+
import com.magento.idea.magento2plugin.actions.generation.data.QueuePublisherData;
10+
import com.magento.idea.magento2plugin.actions.generation.data.QueueTopologyData;
611
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.FieldValidation;
712
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.annotation.RuleRegistry;
813
import com.magento.idea.magento2plugin.actions.generation.dialog.validator.rule.AlphaWithDashRule;
@@ -31,11 +36,13 @@ public class NewMessageQueueDialog extends AbstractDialog {
3136
private static final String HANDLER_TYPE = "Handler Type";
3237
private static final String HANDLER_METHOD = "Handler Method";
3338
private static final String CONSUMER_NAME = "Consumer Name";
34-
private static final String MAX_MESSAGES = "Maximum Messages";
39+
private static final String QUEUE_NAME = "Queue Name";
3540
private static final String CONSUMER_TYPE = "Consumer Type";
41+
private static final String MAX_MESSAGES = "Maximum Messages";
3642
private static final String CONNECTION_NAME = "Connection Name";
3743
private static final String EXCHANGE_NAME = "Exchange Name";
38-
private static final String QUEUE_NAME = "Queue Name";
44+
private static final String BINDING_ID = "Binding ID";
45+
private static final String BINDING_TOPIC = "Binding Topic";
3946

4047
/* TODO: Improve validation */
4148
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
@@ -72,17 +79,25 @@ public class NewMessageQueueDialog extends AbstractDialog {
7279
private JTextField consumerName;
7380

7481
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
75-
message = {NotEmptyRule.MESSAGE, MAX_MESSAGES})
76-
@FieldValidation(rule = RuleRegistry.NUMERIC,
77-
message = {NumericRule.MESSAGE, MAX_MESSAGES})
78-
private JTextField maxMessages;
82+
message = {NotEmptyRule.MESSAGE, QUEUE_NAME})
83+
@FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD,
84+
message = {AlphaWithPeriodRule.MESSAGE, QUEUE_NAME})
85+
@FieldValidation(rule = RuleRegistry.LOWERCASE,
86+
message = {Lowercase.MESSAGE, QUEUE_NAME})
87+
private JTextField queueName;
7988

8089
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
8190
message = {NotEmptyRule.MESSAGE, CONSUMER_TYPE})
8291
@FieldValidation(rule = RuleRegistry.PHP_CLASS,
8392
message = {PhpClassRule.MESSAGE, CONSUMER_TYPE})
8493
private JTextField consumerType;
8594

95+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
96+
message = {NotEmptyRule.MESSAGE, MAX_MESSAGES})
97+
@FieldValidation(rule = RuleRegistry.NUMERIC,
98+
message = {NumericRule.MESSAGE, MAX_MESSAGES})
99+
private JTextField maxMessages;
100+
86101
/* TODO: Can this be made a dropdown? */
87102
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
88103
message = {NotEmptyRule.MESSAGE, CONNECTION_NAME})
@@ -97,12 +112,15 @@ public class NewMessageQueueDialog extends AbstractDialog {
97112
private JTextField exchangeName;
98113

99114
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
100-
message = {NotEmptyRule.MESSAGE, QUEUE_NAME})
101-
@FieldValidation(rule = RuleRegistry.ALPHA_WITH_PERIOD,
102-
message = {AlphaWithPeriodRule.MESSAGE, QUEUE_NAME})
103-
@FieldValidation(rule = RuleRegistry.LOWERCASE,
104-
message = {Lowercase.MESSAGE, QUEUE_NAME})
105-
private JTextField queueName;
115+
message = {NotEmptyRule.MESSAGE, EXCHANGE_NAME})
116+
@FieldValidation(rule = RuleRegistry.ALPHANUMERIC_WITH_UNDERSCORE,
117+
message = {AlphaWithDashRule.MESSAGE, EXCHANGE_NAME})
118+
private JTextField bindingId;
119+
120+
/* TODO: New validation rule */
121+
@FieldValidation(rule = RuleRegistry.NOT_EMPTY,
122+
message = {NotEmptyRule.MESSAGE, EXCHANGE_NAME})
123+
private JTextField bindingTopic;
106124

107125
private JPanel contentPanel;
108126
private JButton buttonOK;
@@ -175,14 +193,86 @@ private void onOK() {
175193
}
176194

177195
private void generateCommunication() {
196+
new QueueCommunicationGenerator(project, new QueueCommunicationData(
197+
getTopicName(),
198+
getHandlerName(),
199+
getHandlerType(),
200+
getHandlerMethod()
201+
)).generate(NewMessageQueueAction.ACTION_NAME, true);
178202
}
179203

180204
private void generateConsumer() {
205+
new QueueConsumerGenerator(project, new QueueConsumerData(
206+
getConsumerName(),
207+
getQueueName(),
208+
getConsumerType(),
209+
getMaxMessages(),
210+
getConnectionName()
211+
)).generate(NewMessageQueueAction.ACTION_NAME, true);
181212
}
182213

183214
private void generateTopology() {
215+
new QueueTopologyGenerator(project, new QueueTopologyData(
216+
getExchangeName(),
217+
getBindingId(),
218+
getBindingTopic(),
219+
getQueueName()
220+
)).generate(NewMessageQueueAction.ACTION_NAME, true);
184221
}
185222

186223
private void generatePublisher() {
224+
new QueuePublisherGenerator(project, new QueuePublisherData(
225+
getTopicName(),
226+
getConnectionName(),
227+
getExchangeName()
228+
)).generate(NewMessageQueueAction.ACTION_NAME, true);
229+
}
230+
231+
public String getTopicName() {
232+
return topicName.getText().trim();
233+
}
234+
235+
public String getHandlerName() {
236+
return handlerName.getText().trim();
237+
}
238+
239+
public String getHandlerType() {
240+
return handlerType.getText().trim();
241+
}
242+
243+
public String getHandlerMethod() {
244+
return handlerMethod.getText().trim();
245+
}
246+
247+
public String getConsumerName() {
248+
return consumerName.getText().trim();
249+
}
250+
251+
public String getQueueName() {
252+
return queueName.getText().trim();
253+
}
254+
255+
public String getConsumerType() {
256+
return consumerType.getText().trim();
257+
}
258+
259+
public String getMaxMessages() {
260+
return maxMessages.getText().trim();
261+
}
262+
263+
public String getConnectionName() {
264+
return connectionName.getText().trim();
265+
}
266+
267+
public String getExchangeName() {
268+
return exchangeName.getText().trim();
269+
}
270+
271+
public String getBindingId() {
272+
return bindingId.getText().trim();
273+
}
274+
275+
public String getBindingTopic() {
276+
return bindingTopic.getText().trim();
187277
}
188278
}

0 commit comments

Comments
 (0)