View Javadoc

1   /*
2    * Copyright 2010 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.fatwire.gst.foundation.taglib;
18  
19  import java.io.IOException;
20  
21  import javax.servlet.jsp.JspException;
22  
23  import COM.FutureTense.Interfaces.ICS;
24  
25  import com.fatwire.gst.foundation.facade.assetapi.asset.ScatteredAssetAccessTemplate;
26  
27  import org.apache.commons.lang.StringUtils;
28  
29  public class AssetSimpleQueryTag extends GsfSimpleTag {
30  
31      private String attributes;
32      private String list;
33      private String query;
34      private String c;
35      private String subtype;
36  
37      /*
38       * (non-Javadoc)
39       * 
40       * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
41       */
42      @Override
43      public void doTag() throws JspException, IOException {
44  
45          final ICS ics = getICS();
46          final ScatteredAssetAccessTemplate t = new ScatteredAssetAccessTemplate(ics);
47  
48          if (StringUtils.isBlank(attributes)) {
49              getJspContext().setAttribute(list, t.query(c, subtype, query));
50          } else {
51              getJspContext().setAttribute(list, t.query(c, subtype, query, attributes.split(",")));
52          }
53  
54          super.doTag();
55      }
56  
57      /**
58       * @param attributes the attributes to set
59       */
60      public void setAttributes(final String attributes) {
61          this.attributes = attributes;
62      }
63  
64      /**
65       * @param list the list to set
66       */
67      public void setList(final String list) {
68          this.list = list;
69      }
70  
71      /**
72       * @param query the query to set
73       */
74      public void setQuery(final String query) {
75          this.query = query;
76      }
77  
78      /**
79       * @param c the c to set
80       */
81      public void setC(String c) {
82          this.c = c;
83      }
84  
85      /**
86       * @param subtype the subtype to set
87       */
88      public void setSubtype(String subtype) {
89          this.subtype = subtype;
90      }
91  
92  }