KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > report > swing > ReportResourceFilter


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.editors.report.swing;
20
21 import java.util.*;
22
23 import org.openharmonise.him.*;
24 import org.openharmonise.him.editors.report.rqom.*;
25 import org.openharmonise.him.swing.resourcetree.*;
26 import org.openharmonise.vfs.*;
27 import org.openharmonise.vfs.metadata.*;
28 import org.openharmonise.vfs.metadata.range.*;
29 import org.openharmonise.vfs.metadata.value.*;
30 import org.openharmonise.vfs.servers.ServerList;
31
32
33 /**
34  * Filters out properties not applicable to the current query scope.
35  * @author MATT TREANOR
36  * @version $Revision: 1.1 $
37  *
38  */

39 public class ReportResourceFilter extends AbstractResourceFilter {
40     private ReportQuery m_query;
41     /**
42      *
43      */

44     public ReportResourceFilter() {
45         super();
46     }
47     public ReportResourceFilter(ReportQuery query) {
48         super();
49         m_query = query;
50     }
51
52     /*
53      * (non-Javadoc)
54      * @see com.simulacramedia.contentmanager.swing.resourcetree.AbstractResourceFilter#checkResource(com.simulacramedia.vfs.VirtualFile)
55      */

56     protected boolean checkResource(VirtualFile vfFile) {
57         boolean bApplicableDomain = false;
58         VirtualFile vfReportFile = ServerList.getInstance().getHarmoniseServer().getVFS().getVirtualFile(m_query.getPath()).getResource();
59         if(vfFile.isDirectory()){
60             Iterator iter = vfFile.getChildren().iterator();
61             while(iter.hasNext()){
62                 String JavaDoc sChild = (String JavaDoc)iter.next();
63                 VirtualFile vfChild = ServerList.getInstance().getHarmoniseServer().getVFS().getVirtualFile(sChild).getResource();
64                 if(checkResource(vfChild)){
65                     bApplicableDomain = true;
66                 }
67             }
68         } else {
69             String JavaDoc sFilePath = vfReportFile.getFullPath();
70             String JavaDoc sPropPath = vfFile.getFullPath();
71             if(sPropPath.indexOf("SYSTEM_PROPS")>0){
72                 if(sPropPath.indexOf("title")<0 && sPropPath.indexOf("description")<0){
73                     return false;
74                 }
75             }
76             Property prop = PropertyCache.getInstance().getPropertyByPath(sPropPath);
77             if(prop.getRange() instanceof PropertyRange){
78                     return false;
79             }
80             List domains = prop.getDomains();
81             Iterator iter = prop.getDomains().iterator();
82             if(domains.size()<=0){
83                 bApplicableDomain = false;
84             }
85             while(iter.hasNext()){
86                 Domain domain = (Domain)iter.next();
87                 if(domain.getResourceType().equals(DomainValue.RESOURCE)){
88                     Iterator iter2 = domain.getPaths().iterator();
89                     while (iter2.hasNext()) {
90                         String JavaDoc sDomainPath = (String JavaDoc) iter2.next();
91                         if(sFilePath.startsWith(sDomainPath) || sDomainPath.startsWith(sFilePath)) {
92                             bApplicableDomain=true;
93                             break;
94                         }
95                     }
96                 }
97                 if(bApplicableDomain){
98                     break;
99                 }
100             }
101         }
102         return bApplicableDomain;
103     }
104
105 }
106
Popular Tags