1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.roo.addon.surf.component;
20
21 import java.util.Collection;
22
23 import org.springframework.roo.shell.CliAvailabilityIndicator;
24 import org.springframework.roo.shell.CliCommand;
25 import org.springframework.roo.shell.CliOption;
26 import org.springframework.roo.shell.CommandMarker;
27 import org.springframework.roo.support.lifecycle.ScopeDevelopmentShell;
28 import org.springframework.roo.support.util.Assert;
29
30
31
32
33
34
35
36 @ScopeDevelopmentShell
37 public class ComponentCommands implements CommandMarker {
38
39 private ComponentOperations componentOperations;
40
41
42
43
44 public ComponentCommands(ComponentOperations componentOperations) {
45 Assert.notNull(componentOperations, "ComponentOperations instance required");
46 this.componentOperations = componentOperations;
47 }
48
49
50
51
52
53 @CliAvailabilityIndicator({"surf webscript list","surf component list","surf component create","surf component resource create","surf component property create"})
54 public boolean isSurfComponentOperationsAvailable() {
55 return componentOperations.isSurfComponentOperationsAvailable();
56 }
57
58
59
60
61
62 @CliCommand(value="surf webscript list", help="Lists all Surf web scripts.")
63 public Collection<String> listSurfComponentTypes() {
64 return componentOperations.listSurfComponentTypes();
65 }
66
67
68
69
70
71
72
73
74 @CliCommand(value="surf component list", help="Lists Surf components in your project.")
75 public Collection<String> listSurfComponents(
76 @CliOption(key={"scope",""}, mandatory=false, help="Specifies scope of the components you want to list. Available options are page, template and component.") String scopeId,
77 @CliOption(key={"page",""}, mandatory=false, help="Specifies page id for the page scoped components you want to list.") String pageId,
78 @CliOption(key={"template",""}, mandatory=false, help="Specifies template id for the template scoped components you want to list.") String templateId
79 ) {
80 return componentOperations.listSurfComponents(scopeId,pageId,templateId);
81 }
82
83
84
85
86
87
88
89
90 @CliCommand(value="surf component create", help="Adds a new Surf component to your Surf project.")
91 public void newComponent(
92 @CliOption(key={"page",""}, mandatory=true, help="Specifies page id of the component to be created.") String pageId,
93 @CliOption(key={"region",""}, mandatory=true, help="Specifies region id of the component to be created.") String regionId,
94 @CliOption(key={"url",""}, mandatory=true, help="Specifies url of the component to be created.") String url,
95 @CliOption(key={"options",""}, mandatory=false, help="Specifies additonal options for the component to be created.") String options
96 ) {
97 componentOperations.createComponent(pageId, regionId, url, options);
98 }
99
100
101
102
103
104
105
106 @CliCommand(value="surf component resource create", help="Creates a new resource for the Surf component.")
107 public void newComponentResource(
108 @CliOption(key={"id",""}, mandatory=true, help="Specifies component instance id of the new component resource.") String componentInstanceId,
109 @CliOption(key={"attributes",""}, mandatory=false, help="Specifies attribute list for the new component resource. The input format is attr1:val1|attr2:val2.") String attributeList,
110 @CliOption(key={"content",""}, mandatory=true, help="Specifies content body of the new component resource") String contentBody
111 ) {
112 componentOperations.createComponentResource(componentInstanceId,attributeList,contentBody);
113 }
114
115
116
117
118
119
120 @CliCommand(value="surf component property create", help="Creates a new property for Surf component.")
121 public void newComponentProperty(
122 @CliOption(key={"id",""}, mandatory=true, help="Specifies component instance id of the new component resource.") String componentInstanceId,
123 @CliOption(key={"properties",""}, mandatory=true, help="Specifies list of the new component properties. The input format is name1:val1|name22:val2.") String propList
124 ) {
125 componentOperations.createComponentProperty(componentInstanceId,propList);
126 }
127
128
129
130
131
132
133
134
135
136 }