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.page;
20
21 import java.util.SortedSet;
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 PageCommands implements CommandMarker {
38
39 private PageOperations pageOperations;
40
41
42
43
44 public PageCommands(PageOperations pageOperations) {
45 Assert.notNull(pageOperations, "PageOperations instance required");
46 this.pageOperations = pageOperations;
47 }
48
49
50
51
52
53 @CliAvailabilityIndicator({"surf page create","surf page association create","surf page list","surf page association list"})
54 public boolean isPageOperationAvailable() {
55 return pageOperations.isPageOperationAvailable();
56 }
57
58
59
60
61
62
63
64
65
66
67
68 @CliCommand(value="surf page create", help="Adds a new page to your Surf project.")
69 public void newPage(
70 @CliOption(key={"id",""}, mandatory=true, help="Specifies id of the page to be created e.g. test, test1") String pageId,
71 @CliOption(key={"path",""}, mandatory=false, specifiedDefaultValue="pages",unspecifiedDefaultValue="pages", help="Specifies path of the page to be created e.g. pages, mypages") String pagePath,
72 @CliOption(key={"templateInstance",""}, mandatory=false, help="Specifies template instance id to be used.") String templateInstance,
73 @CliOption(key={"template",""}, mandatory=false, help="Specifies template id to be used.") String template,
74 @CliOption(key={"urls",""}, mandatory=false, help="Specifies list of urls that the new page to be mapped to. Urls should be separated by comma.") String urls,
75 @CliOption(key={"title",""}, mandatory=false, help="Specifies tile of the page to be created.") String title
76 ) {
77 pageOperations.createPage(pageId,pagePath, templateInstance, template,urls,title);
78 }
79
80
81
82
83
84
85
86
87 @CliCommand(value="surf page association create", help="Adds a new Surf page association between two pages.")
88 public void newPageAssociation(
89 @CliOption(key={"sourceId",""}, mandatory=true, help="Specifies id of the source page.") String sourcePageId,
90 @CliOption(key={"destId",""}, mandatory=true, help="Specifies id of the destination page.") String destPageId,
91 @CliOption(key={"name",""}, mandatory=false, help="Speficies optional name for the association.") String name,
92 @CliOption(key={"type",""}, mandatory=false, specifiedDefaultValue="child",unspecifiedDefaultValue="child", help="Speficies page association type. If not speficied, the default is child.") String type
93 ) {
94 pageOperations.createPageAssociation(name,sourcePageId, destPageId,type);
95 }
96
97
98
99
100
101 @CliCommand(value="surf page list", help="Lists all pages in your Surf project.")
102 public SortedSet<String> listSurfPages() {
103 return pageOperations.listSurfPages();
104 }
105
106
107
108
109
110
111 @CliCommand(value="surf page association list", help="Lists associated pages of the page with a specified id.")
112 public SortedSet<String> listSurfPageAssociations(
113 @CliOption(key={"sourceId",""}, mandatory=true, help="Specifies id of the source page.") String sourceId
114 ) {
115 return pageOperations.listSurfPageAssociations(sourceId);
116 }
117
118 }