DBA Data[Home] [Help]

PACKAGE BODY: APPS.BISM_WEAKAGGREGATES

Source


1 package body bism_weakaggregates as
2 /* $Header: bibasctb.pls 120.2 2006/04/03 05:19:39 akbansal noship $ */
3 procedure associate(fid raw, a_srcpath varchar2,a_tgtpath varchar2,name varchar2,value varchar2, myid raw)
4 is
5 a_srcname bism_objects.object_name%type;
6 a_srcid bism_objects.object_id%type;
7 a_srctypeid bism_objects.object_type_id%type;
8 a_tgtname bism_objects.object_name%type;
9 a_tgtid bism_objects.object_id%type;
10 a_tgttypeid bism_objects.object_type_id%type;
11 ret varchar2(1);
12 -- I need to map the following exceptions
13 invalid_folder_path EXCEPTION;
14 object_not_found EXCEPTION;
15 no_privileges EXCEPTION;
16 insufficient_provileges EXCEPTION;
17 folder_not_found EXCEPTION;
18 
19 PRAGMA EXCEPTION_INIT(invalid_folder_path, -20706);
20 PRAGMA EXCEPTION_INIT(object_not_found,-20200);
21 PRAGMA EXCEPTION_INIT(no_privileges, -20404);
22 PRAGMA EXCEPTION_INIT(insufficient_provileges, -20400);
23 PRAGMA EXCEPTION_INIT(folder_not_found, -20300);
24 
25 begin
26 
27 if name is null or value is null then
28 raise_application_error(BISM_ERRORCODES.INVALID_ARGUMENTS,'Null value specified');
29 end if;
30 
31 -- lookuphelper walks through the path checking privileges all the way down
32 -- the user only needs LIST access on the all but last folders making up
33 -- the path, he needs READ access on the (last) folder where the object resides
34 --check the source object first
35 begin
36 -- a_srcpath will be null if the user specified an empty string in call to
37 -- associate() method in Java, setString(n,"") turns out to be null in plsql
38 -- if it is null in plsql, assume that the user wanted to use fid as src object
39 -- if user called Java API with a null, an exception will be thrown
40 if a_srcpath is not null then
41 bism_core.lookuphelper(fid,a_srcpath,a_srcname,a_srcid,a_srctypeid,myid);
42 else
43 -- when null is supplied for srcname, it means that the user wanted
44 -- this folder to be src object
45 ret := bism_access_control.check_list_access(fid,myid);
46 -- check_list_access will throw an exception if not enough privs
47 a_srcid := fid;
48 a_srctypeid := 100;
49 end if;
50 exception
51 
52 -- check for exceptions and map them as being related to the source object
53 -- so that the caller can distringuish
54 
55 when object_not_found then
56 raise_application_error(BISM_ERRORCODES.SRC_OBJECT_NOT_FOUND,'Source object not found');
57 when no_privileges then
58 raise_application_error(BISM_ERRORCODES.NO_PRIV_SRC_FOLDER,'No privileges for source folder');
59 when insufficient_provileges then
60 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIV_SRC_FOLDER,'Insufficient privileges for source folder');
61 when folder_not_found then
62 raise_application_error(BISM_ERRORCODES.SRC_FOLDER_NOT_FOUND,'Source folder not found');
63 when others then
64 raise;
65 end;
66 
67 begin
68 -- a_tgtpath will be null if the user specified an empty string in call to
69 -- associate() method in Java, setString(n,"") turns out to be null in plsql
70 -- if it is null, assume that the user wanted to use fid as src object
71 
72 if a_tgtpath is not null then
73 bism_core.lookuphelper(fid,a_tgtpath,a_tgtname,a_tgtid,a_tgttypeid,myid);
74 else
75 -- when null is supplied for srcname, it means that the user wanted
76 -- this folder to be src object
77 ret := bism_access_control.check_list_access(fid,myid);
78 a_tgtid := fid;
79 a_tgttypeid := 100;
80 end if;
81 
82 exception
83 
84 -- check for exceptions and map them as being related to the target object
85 -- so that the caller can distringuish
86 
87 when object_not_found then
88 raise_application_error(BISM_ERRORCODES.TGT_OBJECT_NOT_FOUND,'Target object not found');
89 when no_privileges then
90 raise_application_error(BISM_ERRORCODES.NO_PRIV_TGT_FOLDER,'No privileges for target folder');
91 when insufficient_provileges then
92 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIV_TGT_FOLDER,'Insufficient privileges for target folder');
93 when folder_not_found then
94 raise_application_error(BISM_ERRORCODES.TGT_FOLDER_NOT_FOUND,'Target folder not found');
95 when others then
96 raise;
97 end;
98 
99 --if something went wrong, it would have thrown exception by now, so every thing
100 -- is a OK
101 insert into bism_associates (source_id,target_id,name,value) values (a_srcid,a_tgtid,name,value);
102 -- if there is any exceptions, let it bubble up
103 
104 end;
105 
106 procedure dissociate(fid raw, a_srcpath varchar2, a_name varchar2, a_value varchar2,myid raw)
107 is
108 ret varchar2(1);
109 a_srcname bism_objects.object_name%type;
110 a_srcid bism_objects.object_id%type;
111 a_srctypeid bism_objects.object_type_id%type;
112 rows_deleted integer:= 0;
113 
114 invalid_folder_path EXCEPTION;
115 object_not_found EXCEPTION;
116 no_privileges EXCEPTION;
117 insufficient_provileges EXCEPTION;
118 folder_not_found EXCEPTION;
119 
120 PRAGMA EXCEPTION_INIT(invalid_folder_path, -20706);
121 PRAGMA EXCEPTION_INIT(object_not_found,-20200);
122 PRAGMA EXCEPTION_INIT(no_privileges, -20404);
123 PRAGMA EXCEPTION_INIT(insufficient_provileges, -20400);
124 PRAGMA EXCEPTION_INIT(folder_not_found, -20300);
125 
126 begin
127 
128 
129 -- lookuphelper walks through the path checking privileges all the way down
130 -- the caller only needs list access on the last but one folders making up
131 -- the path but he needs READ access on the folder where the object resides
132 
133 begin
134 
135 -- a_srcpath will be null if the user specified an empty string in call to
136 -- dissociate() method in Java, setString(n,"") turns out to be null in plsql
137 -- if it is null, assume that the user wanted to use fid as src object
138 
139 if a_srcpath is not null then
140 bism_core.lookuphelper(fid,a_srcpath,a_srcname,a_srcid,a_srctypeid,myid);
141 else
142 ret := bism_access_control.check_list_access(fid,myid);
143 a_srcid := fid;
144 a_srctypeid := 100;
145 end if;
146 -- check for exceptions and map them as being related to the source object
147 -- so that the caller can distringuish
148 exception
149 when object_not_found then
150 raise_application_error(BISM_ERRORCODES.SRC_OBJECT_NOT_FOUND,'Source object not found');
151 when no_privileges then
152 raise_application_error(BISM_ERRORCODES.NO_PRIV_SRC_FOLDER,'No privileges for source folder');
153 when insufficient_provileges then
154 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIV_SRC_FOLDER,'Insufficient privileges for source folder');
155 when folder_not_found then
156 raise_application_error(BISM_ERRORCODES.SRC_FOLDER_NOT_FOUND,'Source folder not found');
157 when others then
158 raise;
159 end;
160 
161 -- we dont care about the target object, because the uniqueness lies
162 -- in source-name-value
163 
164 --if something went wrong, it would have thrown exception by now, so every thing
165 -- is a OK
166 
167 if a_srcid is not null and a_name is null then
168 delete from bism_associates where source_id = a_srcid;
169 elsif a_srcid is not null and a_name is not null and a_value is null then
170 delete from bism_associates where source_id = a_srcid and name = a_name;
171 else
172 delete from bism_associates where source_id = a_srcid and name = a_name and value = a_value;
173 end if;
174 
175 rows_deleted := SQL%ROWCOUNT;
176 if rows_deleted = 0 then
177 raise_application_error(BISM_ERRORCODES.ASSOCIATION_NOT_FOUND, 'Association not found');
178 end if;
179 -- if there is any exceptions, let it bubble up
180 
181 end;
182 
183 function get_associate(fid raw,a_srcpath varchar2,a_attrname varchar2,a_attrvalue varchar2,myid raw)
184 return myrctype
185 is
186 rc myrctype;
187 ret varchar2(1);
188 a_srcname bism_objects.object_name%type;
189 a_srcid bism_objects.object_id%type;
190 a_srctypeid bism_objects.object_type_id%type;
191 b_tgtid bism_objects.object_id%type;
192 invalid_folder_path EXCEPTION;
193 object_not_found EXCEPTION;
194 no_privileges EXCEPTION;
195 insufficient_provileges EXCEPTION;
196 folder_not_found EXCEPTION;
197 
198 PRAGMA EXCEPTION_INIT(invalid_folder_path, -20706);
199 PRAGMA EXCEPTION_INIT(object_not_found,-20200);
200 PRAGMA EXCEPTION_INIT(no_privileges, -20404);
201 PRAGMA EXCEPTION_INIT(insufficient_provileges, -20400);
202 PRAGMA EXCEPTION_INIT(folder_not_found, -20300);
203 
204 begin
205 
206 -- let the caller check the validity of the input arguments
207 
208 begin
209 
210 if a_srcpath is not null then
211 bism_core.lookuphelper(fid,a_srcpath,a_srcname,a_srcid,a_srctypeid,myid);
212 else
213 ret := bism_access_control.check_list_access(fid,myid);
214 a_srcid := fid;
215 end if;
216 -- check for exceptions and map them as being related to the source object
217 -- so that the caller can distringuish
218 exception
219 when object_not_found then
220 raise_application_error(BISM_ERRORCODES.SRC_OBJECT_NOT_FOUND,'Source object not found');
221 when no_privileges then
222 raise_application_error(BISM_ERRORCODES.NO_PRIV_SRC_FOLDER,'No privileges for source folder');
223 when insufficient_provileges then
224 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIV_SRC_FOLDER,'Insufficient privileges for source folder');
225 when folder_not_found then
226 raise_application_error(BISM_ERRORCODES.SRC_FOLDER_NOT_FOUND,'Source folder not found');
227 when others then
228 raise;
229 end;
230 
231 begin
232 select target_id into b_tgtid from bism_associates where source_id = a_srcid and name = a_attrname and value = a_attrvalue;
233 exception
234 when no_data_found then
235 raise_application_error(BISM_ERRORCODES.ASSOCIATION_NOT_FOUND,'Association not found');
236 when others then
237 raise;
238 end;
239 
240 return object_load(b_tgtid);
241 end;
242 
243 function object_load (objid raw) return myrctype
244 is
245 rc myrctype;
246 begin
247 
248 begin
249 -- this method is not being used currently !!
250 -- the foll. sql stmt is m_fetchObjectsSQL2 inside SQLBuilder
251 open rc for SELECT T.USER_VISIBLE, T.OBJECT_TYPE_ID, T.VERSION, T.TIME_DATE_CREATED,
252 T.TIME_DATE_MODIFIED, T.OBJECT_ID,T.FOLDER_ID, T.CREATED_BY,
253 T.LAST_MODIFIED_BY, T.OBJECT_NAME, T.TITLE, T.APPLICATION, T.DATABASE, T.DESCRIPTION,
254 T.KEYWORDS, T.XML, T.APPLICATION_SUBTYPE1, T.COMP_SUBTYPE1, T.COMP_SUBTYPE2,T.COMP_SUBTYPE3,T.TIME_DATE_LAST_ACCESSED,
255 T.container_id,T.aggregate_info from
256 (
257 SELECT A.USER_VISIBLE, A.OBJECT_TYPE_ID, A.VERSION, A.TIME_DATE_CREATED,
258 A.TIME_DATE_MODIFIED, A.OBJECT_ID,A.FOLDER_ID, A.CREATED_BY,
259 A.LAST_MODIFIED_BY, A.OBJECT_NAME, A.TITLE, A.APPLICATION, A.DATABASE, A.DESCRIPTION,
260 A.KEYWORDS, A.XML, A.APPLICATION_SUBTYPE1, A.COMP_SUBTYPE1, A.COMP_SUBTYPE2,A.COMP_SUBTYPE3, A.TIME_DATE_LAST_ACCESSED,
261 T1.container_id,T1.aggregate_info
262 from bism_objects A,
263 (
264 select distinct containee_id,container_id,aggregate_info from bism_aggregates start with containee_id = objid and container_id='30' connect by container_id = prior containee_id
265 order siblings by containee_id
266 )
267 T1
268 where A.object_id=T1.containee_id
269 )
270 T ;
271 return rc;
272 exception
273 when no_data_found then
274 raise_application_error(BISM_ERRORCODES.OBJECT_NOT_FOUND,'Object not found');
275 when others then
276 raise;
277 end;
278 
279 end;
280 
281 procedure get(fid raw,path varchar2,a_objname out nocopy varchar2,a_objid out nocopy raw,a_typeid out nocopy number,myid raw,startpos in out nocopy integer,folderid out nocopy raw)
282 is
283 oid bism_objects.object_id%type;
284 typeid bism_objects.object_type_id%type;
285 oname bism_objects.object_name%type;
286 ret varchar2(1) := 'n';
287 visible bism_objects.user_visible%type;
288 newstr varchar2(2000) := '';
289 len integer :=0;
290 len1 integer :=0;
291 begin
292 -- using '\' as delimeter for now, this can be changed
293 -- note : the delimeter can be longer than one char
294 -- get_next_element will match the delimeter string
295 newstr := bism_core.get_next_element(path,'/',startpos);
296 len := nvl(length(newstr),0);
297 if len <> 0 then
298     begin
299     select object_id,object_type_id,object_name,user_visible into oid,typeid,oname,visible from bism_objects where folder_id = fid and object_name = newstr and user_visible = 'Y';
300     ret := bism_access_control.check_list_access(fid,myid);
301 
302     if ret = 'y' then
303         -- when the given string does not contain the delimiter any more
304         -- get_next_element function will set startpos to zero
305         -- indicating end of path
306         if startpos <> 0 then
307         	get(oid,path,a_objname,a_objid,a_typeid,myid,startpos,folderid);
308         else
309             -- if no more path, set the obj name, id and type
310             -- of the last object in the path
311 		folderid := fid;
312             a_objname := oname;
313             a_objid := oid;
314             a_typeid := typeid;
315         end if;
316     end if;
317     exception
318     when no_data_found then
319     raise_application_error(BISM_ERRORCODES.OBJECT_NOT_FOUND,'Object not found');
320     end;
321 else
322 raise_application_error(BISM_ERRORCODES.INVALID_FOLDER_PATH,'Invalid atomic name');
323 end if;
324 
325 end;
326 
327 function verify_source(fid raw,a_srcpath varchar2,myid raw,folderid out nocopy raw)
328 return raw
329 is
330 rc bism_weakaggregates.myrctype;
331 a_srcname bism_objects.object_name%type;
332 a_srcid bism_objects.object_id%type;
333 a_srctypeid bism_objects.object_type_id%type;
334 
335 invalid_folder_path EXCEPTION;
336 object_not_found EXCEPTION;
337 no_privileges EXCEPTION;
338 insufficient_provileges EXCEPTION;
339 folder_not_found EXCEPTION;
340 
341 PRAGMA EXCEPTION_INIT(invalid_folder_path, -20706);
342 PRAGMA EXCEPTION_INIT(object_not_found,-20200);
343 PRAGMA EXCEPTION_INIT(no_privileges, -20404);
344 PRAGMA EXCEPTION_INIT(insufficient_provileges, -20400);
345 PRAGMA EXCEPTION_INIT(folder_not_found, -20300);
346 a_objname bism_objects.object_name%type;
347 a_objid bism_objects.object_id%type;
348 a_typeid bism_objects.object_type_id%type;
349 startpos integer := 1;-- unparsed string, so start at 1
350 ret varchar2(1);
351 
352 begin
353 
354 -- let the caller check the validity of the input arguments
355 
356 begin
357 if a_srcpath is not null then
358 get(fid ,a_srcpath ,a_srcname ,a_srcid ,a_srctypeid ,myid ,startpos,folderid);
359 return a_srcid;
360 else
361 -- when user supplies an empty string into Java listAssociates() API
362 -- that methods binds "" to the bind variable which turns out to be
363 -- a null in plsql.
364 ret := bism_access_control.check_list_access(fid,myid);
365 if ret = 'y' then
366 folderid := fid;
367 return fid;
368 end if;
369 end if;
370 exception
371 when object_not_found then
372 raise_application_error(BISM_ERRORCODES.SRC_OBJECT_NOT_FOUND,'Source object not found');
373 when no_privileges then
374 raise_application_error(BISM_ERRORCODES.NO_PRIV_SRC_FOLDER,'No privileges for source folder');
375 when insufficient_provileges then
376 raise_application_error(BISM_ERRORCODES.INSUFFICIENT_PRIV_SRC_FOLDER,'Insufficient privileges for source folder');
377 when folder_not_found then
378 raise_application_error(BISM_ERRORCODES.SRC_FOLDER_NOT_FOUND,'Source folder not found');
379 when others then
380 raise;
381 end;
382 
383 end;
384 
385 end;