KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > engine > jasperreports > util > RepositoryContext


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.api.engine.jasperreports.util;
22
23 import com.jaspersoft.jasperserver.api.common.domain.ExecutionContext;
24 import com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.CompiledReportProvider;
25 import com.jaspersoft.jasperserver.api.metadata.common.domain.Folder;
26 import com.jaspersoft.jasperserver.api.metadata.common.service.RepositoryService;
27 import com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit;
28
29 /**
30  * @author Lucian Chirita (lucianc@users.sourceforge.net)
31  * @version $Id: RepositoryContext.java 3650 2006-06-12 10:49:06Z lucian $
32  */

33 public class RepositoryContext {
34     
35     private RepositoryService repository;
36     private ExecutionContext executionContext;
37     private String JavaDoc contextURI;
38     private ReportUnit reportUnit;
39     private CompiledReportProvider compiledReportProvider;
40     
41     public RepositoryContext() {
42     }
43
44     public RepositoryService getRepository() {
45         return repository;
46     }
47
48     public void setRepository(RepositoryService repository) {
49         this.repository = repository;
50     }
51
52     public String JavaDoc getContextURI() {
53         return contextURI;
54     }
55
56     public void setContextURI(String JavaDoc contextURI) {
57         this.contextURI = contextURI;
58     }
59
60     
61     /**
62      * Sets the context URI as the context of local resource for a resource.
63      * <p>
64      * The repository service needs to be set before calling this method.
65      *
66      * @param resourceURI the resource URI
67      * @see #setRepository(RepositoryService)
68      */

69     public void setContextResourceURI(String JavaDoc resourceURI) {
70         int lastSepIdx = resourceURI.lastIndexOf(Folder.SEPARATOR);
71         String JavaDoc resourceName;
72         String JavaDoc folder;
73         if (lastSepIdx >= 0) {
74             resourceName = resourceURI.substring(lastSepIdx + Folder.SEPARATOR_LENGTH);
75             folder = resourceURI.substring(0, lastSepIdx + Folder.SEPARATOR_LENGTH);
76         } else {
77             resourceName = resourceURI;
78             folder = "";
79         }
80         String JavaDoc childrenFolderName = getRepository().getChildrenFolderName(resourceName);
81         String JavaDoc childrenFolderURI = folder + childrenFolderName;
82         setContextURI(childrenFolderURI);
83     }
84
85     public ExecutionContext getExecutionContext() {
86         return executionContext;
87     }
88
89     public void setExecutionContext(ExecutionContext executionContext) {
90         this.executionContext = executionContext;
91     }
92
93     public ReportUnit getReportUnit() {
94         return reportUnit;
95     }
96
97     public void setReportUnit(ReportUnit reportUnit) {
98         this.reportUnit = reportUnit;
99     }
100
101     public CompiledReportProvider getCompiledReportProvider() {
102         return compiledReportProvider;
103     }
104
105     public void setCompiledReportProvider(CompiledReportProvider compiledReportProvider) {
106         this.compiledReportProvider = compiledReportProvider;
107     }
108
109 }
110
Popular Tags