Skip to content

Commit dc75370

Browse files
author
Adam Tuttle
committedNov 15, 2011
Contributions from Ray Camden: collection, index, search
1 parent f09906d commit dc75370

File tree

5 files changed

+507
-1
lines changed

5 files changed

+507
-1
lines changed
 

‎base.cfc

100644100755
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,60 @@
574574
</cfif>
575575
<cfreturn tagResult>
576576
</cfcase>
577+
578+
<!--- cfsearch service --->
579+
<cfcase value="CFSEARCH">
580+
<cfset var searchResult = {}>
581+
<cfset var localname = "cfsearch_" & replace(createUUID(), "-","_","all")>
582+
<cfif structKeyExists(tagAttributes, "status") and trim(tagAttributes["status"]) neq "">
583+
<cfset var statusname = "cfsearchstatus_" & replace(createUUID(), "-","_","all")>
584+
<cfset tagAttributes.status = "local.#statusname#">
585+
</cfif>
586+
<cfsearch attributeCollection="#tagAttributes#" name="local.#localname#">
587+
<cfset searchResult.name = local[localname]>
588+
<cfif structKeyExists(tagAttributes, "status") and trim(tagAttributes["status"]) neq "">
589+
<cfset searchResult.status = local[statusname]>
590+
</cfif>
591+
592+
<cfset tagResult.setResult(searchResult)>
593+
<cfreturn tagResult>
594+
</cfcase>
595+
596+
<!--- cfindex service --->
597+
<cfcase value="CFINDEX">
598+
<cfset var indexResult = {}>
599+
<cfif structKeyExists(tagAttributes, "status") and trim(tagAttributes["status"]) neq "">
600+
<cfset var statusname = "cfsearchstatus_" & replace(createUUID(), "-","_","all")>
601+
<cfset tagAttributes.status = "local.#statusname#">
602+
</cfif>
603+
<cfif structKeyExists(tagAttributes,"query")>
604+
<cfset local.query = tagAttributes.query>
605+
<cfset tagAttributes.query = "local.query">
606+
</cfif>
607+
<cfindex attributeCollection="#tagAttributes#">
608+
<cfif structKeyExists(tagAttributes, "status") and trim(tagAttributes["status"]) neq "">
609+
<cfset indexResult.status = local[statusname]>
610+
</cfif>
611+
612+
<cfset tagResult.setResult(indexResult)>
613+
<cfreturn tagResult>
614+
</cfcase>
615+
616+
<!--- cfcollection service --->
617+
<cfcase value="CFCOLLECTION">
618+
<cfset var colResult = {}>
619+
<cfset var localname = "cfcollection_" & replace(createUUID(), "-","_","all")>
620+
<cfif listFindNoCase("list,categoryList",tagAttributes.action)>
621+
<cfset tagAttributes.name = "local.#localname#">
622+
</cfif>
623+
<cfcollection attributeCollection="#tagAttributes#">
624+
<cfif structKeyExists(tagAttributes, "name")>
625+
<cfset colResult.name = local[localname]>
626+
</cfif>
627+
<cfset tagResult.setResult(colResult)>
628+
<cfreturn tagResult>
629+
</cfcase>
630+
577631
</cfswitch>
578632
</cffunction>
579633
</cfcomponent>

‎collection.cfc

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/***********************************************************************************************************
2+
*
3+
* Made by Raymond Camden, Jedi Master
4+
*
5+
* MIT License
6+
*
7+
* Copyright (c) 2011 The ColdFusion Community
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
10+
* associated documentation files (the "Software"), to deal in the Software without restriction, including
11+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
13+
* following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or substantial
16+
* portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
19+
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
20+
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* See also: http://www.opensource.org/licenses/mit-license.html
25+
*
26+
*************************************************************************************************************/
27+
28+
/**
29+
* Collection Service to perform solr collection operations in cfscript
30+
* @name collection
31+
* @displayname ColdFusion Collection Service
32+
* @output false
33+
* @accessors true
34+
*/
35+
component extends="base" {
36+
37+
property string action;
38+
property string categories;
39+
property string collection;
40+
property string engine;
41+
property string language;
42+
property string name;
43+
property string path;
44+
45+
property name="properties" type="any" getter="false" setter="false";
46+
47+
//service tag to invoke
48+
variables.tagName = "CFCOLLECTION";
49+
50+
//cfcollection tag attributes
51+
variables.tagAttributes = getSupportedTagAttributes(getTagName());
52+
53+
/**
54+
* Default constructor invoked when search objects are created.
55+
* @return search object
56+
* @output false
57+
*/
58+
public collection function init()
59+
{
60+
if(!structisempty(arguments)) structappend(variables,arguments);
61+
return this;
62+
}
63+
64+
65+
/**
66+
* Invoke the cfcollection service tag to get categories for a collection
67+
* Usage :: new collection().categoryList(collection="fivetag");
68+
* @output false
69+
*/
70+
public struct function categoryList()
71+
{
72+
//store tag attributes to be passed to the service tag in a local variable
73+
var tagAttributes = duplicate(getTagAttributes());
74+
75+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
76+
if (!structisempty(arguments))
77+
{
78+
structappend(tagAttributes,arguments);
79+
}
80+
81+
tagAttributes.action="categorylist";
82+
83+
//trim attribute values
84+
tagAttributes = trimAttributes(tagAttributes);
85+
86+
return super.invokeTag(getTagName(),tagAttributes);
87+
}
88+
89+
/**
90+
* Invoke the cfcollection service tag to create collections
91+
* Usage :: new collection().create(collection="fivetag",path="c...");
92+
* @output false
93+
*/
94+
public struct function create()
95+
{
96+
//store tag attributes to be passed to the service tag in a local variable
97+
var tagAttributes = duplicate(getTagAttributes());
98+
99+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
100+
if (!structisempty(arguments))
101+
{
102+
structappend(tagAttributes,arguments);
103+
}
104+
105+
tagAttributes.action="create";
106+
107+
//trim attribute values
108+
tagAttributes = trimAttributes(tagAttributes);
109+
110+
return super.invokeTag(getTagName(),tagAttributes);
111+
}
112+
113+
/**
114+
* Invoke the cfcollection service tag to delete collections
115+
* Usage :: new collection().delete(collection="boom");
116+
* @output false
117+
*/
118+
public struct function delete()
119+
{
120+
//store tag attributes to be passed to the service tag in a local variable
121+
var tagAttributes = duplicate(getTagAttributes());
122+
123+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
124+
if (!structisempty(arguments))
125+
{
126+
structappend(tagAttributes,arguments);
127+
}
128+
129+
tagAttributes.action="delete";
130+
131+
//trim attribute values
132+
tagAttributes = trimAttributes(tagAttributes);
133+
134+
return super.invokeTag(getTagName(),tagAttributes);
135+
}
136+
137+
/**
138+
* Invoke the cfcollection service tag to list solr collections in cfscript
139+
* Usage :: new collection().list();
140+
* @output false
141+
*/
142+
public struct function list()
143+
{
144+
//store tag attributes to be passed to the service tag in a local variable
145+
var tagAttributes = duplicate(getTagAttributes());
146+
147+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
148+
if (!structisempty(arguments))
149+
{
150+
structappend(tagAttributes,arguments);
151+
}
152+
153+
tagAttributes.action="list";
154+
155+
//trim attribute values
156+
tagAttributes = trimAttributes(tagAttributes);
157+
158+
return super.invokeTag(getTagName(),tagAttributes);
159+
}
160+
161+
/**
162+
* Invoke the cfcollection service tag to optimize collections
163+
* Usage :: new collection().optimize(collection="boom");
164+
* @output false
165+
*/
166+
public struct function optimize()
167+
{
168+
//store tag attributes to be passed to the service tag in a local variable
169+
var tagAttributes = duplicate(getTagAttributes());
170+
171+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
172+
if (!structisempty(arguments))
173+
{
174+
structappend(tagAttributes,arguments);
175+
}
176+
177+
tagAttributes.action="optimize";
178+
179+
//trim attribute values
180+
tagAttributes = trimAttributes(tagAttributes);
181+
182+
return super.invokeTag(getTagName(),tagAttributes);
183+
}
184+
185+
186+
}

‎index.cfc

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/***********************************************************************************************************
2+
*
3+
* Made by Raymond Camden, Jedi Master
4+
*
5+
* MIT License
6+
*
7+
* Copyright (c) 2011 The ColdFusion Community
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
10+
* associated documentation files (the "Software"), to deal in the Software without restriction, including
11+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
13+
* following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or substantial
16+
* portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
19+
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
20+
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* See also: http://www.opensource.org/licenses/mit-license.html
25+
*
26+
*************************************************************************************************************/
27+
28+
/**
29+
* Index Service to perform solr index operations in cfscript
30+
* @name index
31+
* @displayname ColdFusion Index Service
32+
* @output false
33+
* @accessors true
34+
*/
35+
component extends="base" {
36+
37+
property string action;
38+
property string collection;
39+
property string body;
40+
property string category;
41+
property string categoryTree;
42+
property string custom1;
43+
property string custom2;
44+
property string custom3;
45+
property string custom4;
46+
property string extensions;
47+
property string key;
48+
property string language;
49+
property string prefix;
50+
property string query;
51+
property string status;
52+
property string title;
53+
property string type;
54+
property string urlpath;
55+
56+
property name="properties" type="any" getter="false" setter="false";
57+
58+
//service tag to invoke
59+
variables.tagName = "CFINDEX";
60+
61+
//cfcollection tag attributes
62+
variables.tagAttributes = getSupportedTagAttributes(getTagName());
63+
64+
/**
65+
* Default constructor invoked when search objects are created.
66+
* @return search object
67+
* @output false
68+
*/
69+
public index function init()
70+
{
71+
if(!structisempty(arguments)) structappend(variables,arguments);
72+
return this;
73+
}
74+
75+
/**
76+
* Invoke the cfindex service tag to delete keys from solr collections in cfscript
77+
* Usage :: new index().delete(collection="beer",key=9);
78+
* @output false
79+
*/
80+
public struct function delete()
81+
{
82+
//store tag attributes to be passed to the service tag in a local variable
83+
var tagAttributes = duplicate(getTagAttributes());
84+
85+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
86+
if (!structisempty(arguments))
87+
{
88+
structappend(tagAttributes,arguments);
89+
}
90+
91+
tagAttributes.action="delete";
92+
93+
//trim attribute values
94+
tagAttributes = trimAttributes(tagAttributes);
95+
96+
return super.invokeTag(getTagName(),tagAttributes);
97+
}
98+
99+
/**
100+
* Invoke the cfindex service tag to purge a solr collection in cfscript
101+
* Usage :: new index().purge(collection="beer");
102+
* @output false
103+
*/
104+
public struct function purge()
105+
{
106+
//store tag attributes to be passed to the service tag in a local variable
107+
var tagAttributes = duplicate(getTagAttributes());
108+
109+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
110+
if (!structisempty(arguments))
111+
{
112+
structappend(tagAttributes,arguments);
113+
}
114+
115+
tagAttributes.action="purge";
116+
117+
//trim attribute values
118+
tagAttributes = trimAttributes(tagAttributes);
119+
120+
return super.invokeTag(getTagName(),tagAttributes);
121+
}
122+
123+
/**
124+
* Invoke the cfindex service tag to refresh solr collections in cfscript
125+
* Usage :: new index().refresh(collection="beer",query=q);
126+
* @output false
127+
*/
128+
public struct function refresh()
129+
{
130+
//store tag attributes to be passed to the service tag in a local variable
131+
var tagAttributes = duplicate(getTagAttributes());
132+
133+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
134+
if (!structisempty(arguments))
135+
{
136+
structappend(tagAttributes,arguments);
137+
}
138+
139+
tagAttributes.action="refresh";
140+
141+
//trim attribute values
142+
tagAttributes = trimAttributes(tagAttributes);
143+
144+
return super.invokeTag(getTagName(),tagAttributes);
145+
}
146+
147+
/**
148+
* Invoke the cfindex service tag to refresh solr collections in cfscript
149+
* Usage :: new index().refresh(collection="beer",query=q);
150+
* @output false
151+
*/
152+
public struct function update()
153+
{
154+
//store tag attributes to be passed to the service tag in a local variable
155+
var tagAttributes = duplicate(getTagAttributes());
156+
157+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
158+
if (!structisempty(arguments))
159+
{
160+
structappend(tagAttributes,arguments);
161+
}
162+
163+
tagAttributes.action="update";
164+
165+
//trim attribute values
166+
tagAttributes = trimAttributes(tagAttributes);
167+
168+
return super.invokeTag(getTagName(),tagAttributes);
169+
}
170+
171+
}

‎readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ These are the tags that need to be ported over to script. Godspeed!
1919

2020
## Significant omissions:
2121

22-
* cfcollection
2322
* cfexchangecalendar
2423
* cfexchangeconnection
2524
* cfexchangecontact

‎search.cfc

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/***********************************************************************************************************
2+
*
3+
* Made by Raymond Camden, Jedi Master
4+
*
5+
* MIT License
6+
*
7+
* Copyright (c) 2011 The ColdFusion Community
8+
*
9+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
10+
* associated documentation files (the "Software"), to deal in the Software without restriction, including
11+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
13+
* following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in all copies or substantial
16+
* portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
19+
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
20+
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21+
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
*
24+
* See also: http://www.opensource.org/licenses/mit-license.html
25+
*
26+
*************************************************************************************************************/
27+
28+
/**
29+
* Search Service to perform search operations in cfscript
30+
* @name search
31+
* @displayname ColdFusion Search Service
32+
* @output false
33+
* @accessors true
34+
*/
35+
component extends="base" {
36+
37+
property string collection;
38+
//property string name;
39+
property string category;
40+
property string categoryTree;
41+
property numeric contextBytes;
42+
property string contextHighlightBegin;
43+
property string contextHighlightEnd;
44+
property numeric contextPassages;
45+
property string criteria;
46+
//Language is deprecated
47+
property numeric maxRows;
48+
property string previousCriteria;
49+
property numeric startRow;
50+
property string status;
51+
property string suggestions;
52+
property string orderby;
53+
//Type is deprecated
54+
55+
property name="properties" type="any" getter="false" setter="false";
56+
57+
//service tag to invoke
58+
variables.tagName = "CFSEARCH";
59+
60+
//cffeed tag attributes
61+
variables.tagAttributes = getSupportedTagAttributes(getTagName());
62+
63+
/**
64+
* Default constructor invoked when search objects are created.
65+
* @return search object
66+
* @output false
67+
*/
68+
public search function init()
69+
{
70+
if(!structisempty(arguments)) structappend(variables,arguments);
71+
return this;
72+
}
73+
74+
/**
75+
* Invoke the cfsearch service tag to search solr collections in cfscript
76+
* Usage :: new search().search(criteria="foo",maxRows=10);
77+
* @output false
78+
*/
79+
public struct function search()
80+
{
81+
//store tag attributes to be passed to the service tag in a local variable
82+
var tagAttributes = duplicate(getTagAttributes());
83+
84+
//attributes passed to service tag action like send() override existing attributes and are discarded after the action
85+
if (!structisempty(arguments))
86+
{
87+
structappend(tagAttributes,arguments);
88+
}
89+
90+
//trim attribute values
91+
tagAttributes = trimAttributes(tagAttributes);
92+
93+
return super.invokeTag(getTagName(),tagAttributes);
94+
}
95+
96+
}

0 commit comments

Comments
 (0)
Please sign in to comment.