KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencrx > kernel > layer > application > DerivedReferences


1 /*
2  * ====================================================================
3  * Project: opencrx, http://www.opencrx.org/
4  * Name: $Id: DerivedReferences.java,v 1.25 2006/03/21 22:24:41 wfro Exp $
5  * Description: openCRX application plugin
6  * Revision: $Revision: 1.25 $
7  * Owner: CRIXP AG, Switzerland, http://www.crixp.com
8  * Date: $Date: 2006/03/21 22:24:41 $
9  * ====================================================================
10  *
11  * This software is published under the BSD license
12  * as listed below.
13  *
14  * Copyright (c) 2004-2005, CRIXP Corp., Switzerland
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  *
21  * * Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  *
24  * * Redistributions in binary form must reproduce the above copyright
25  * notice, this list of conditions and the following disclaimer in
26  * the documentation and/or other materials provided with the
27  * distribution.
28  *
29  * * Neither the name of CRIXP Corp. nor the names of the contributors
30  * to openCRX may be used to endorse or promote products derived
31  * from this software without specific prior written permission
32  *
33  *
34  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
35  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
36  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
37  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
39  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
40  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
41  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
43  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46  * POSSIBILITY OF SUCH DAMAGE.
47  *
48  * ------------------
49  *
50  * This product includes software developed by the Apache Software
51  * Foundation (http://www.apache.org/).
52  *
53  * This product includes software developed by contributors to
54  * openMDX (http://www.openmdx.org/)
55  */

56
57 package org.opencrx.kernel.layer.application;
58
59 import java.util.ArrayList JavaDoc;
60 import java.util.Arrays JavaDoc;
61 import java.util.HashMap JavaDoc;
62 import java.util.HashSet JavaDoc;
63 import java.util.Iterator JavaDoc;
64 import java.util.List JavaDoc;
65 import java.util.Map JavaDoc;
66 import java.util.Set JavaDoc;
67
68 import org.openmdx.base.accessor.jmi.cci.RefPackage_1_0;
69 import org.openmdx.base.exception.ServiceException;
70 import org.openmdx.compatibility.base.dataprovider.cci.AttributeSelectors;
71 import org.openmdx.compatibility.base.dataprovider.cci.AttributeSpecifier;
72 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject;
73 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderObject_1_0;
74 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderReply;
75 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderReplyContexts;
76 import org.openmdx.compatibility.base.dataprovider.cci.DataproviderRequest;
77 import org.openmdx.compatibility.base.dataprovider.cci.Directions;
78 import org.openmdx.compatibility.base.dataprovider.cci.Orders;
79 import org.openmdx.compatibility.base.dataprovider.cci.RequestCollection;
80 import org.openmdx.compatibility.base.dataprovider.cci.ServiceHeader;
81 import org.openmdx.compatibility.base.dataprovider.cci.SystemAttributes;
82 import org.openmdx.compatibility.base.dataprovider.spi.Layer_1_0;
83 import org.openmdx.compatibility.base.naming.Path;
84 import org.openmdx.compatibility.base.query.FilterOperators;
85 import org.openmdx.compatibility.base.query.FilterProperty;
86 import org.openmdx.compatibility.base.query.Quantors;
87 import org.openmdx.model1.accessor.basic.cci.Model_1_0;
88 import org.openmdx.uses.org.apache.commons.collections.MapUtils;
89
90 public class DerivedReferences {
91
92     //-----------------------------------------------------------------------
93
public DerivedReferences(
94         Model_1_0 model,
95         OpenCrxKernel_1 plugin,
96         Layer_1_0 delegation,
97         RefPackage_1_0 rootPkg
98     ) {
99         this.model = model;
100         this.plugin = plugin;
101         this.delegation = delegation;
102         this.rootPkg = rootPkg;
103     }
104         
105     //-------------------------------------------------------------------------
106
private DataproviderRequest remapFindRequest(
107         DataproviderRequest request,
108         Path reference,
109         FilterProperty[] additionalFilter
110     ) throws ServiceException {
111         for(int i = 0; i < additionalFilter.length; i++) {
112             request.addAttributeFilterProperty(
113                 additionalFilter[i]
114             );
115         }
116         return new DataproviderRequest(
117             request,
118             new DataproviderObject(
119                 reference
120             ),
121             request.operation(),
122             request.attributeFilter(),
123             request.position(),
124             request.size(),
125             request.direction(),
126             request.attributeSelector(),
127             request.attributeSpecifier()
128         );
129     }
130     
131     //-------------------------------------------------------------------------
132
public DataproviderReply getReply(
133         ServiceHeader header,
134         DataproviderRequest request
135     ) throws ServiceException {
136         
137         DataproviderReply reply = null;
138             
139         // GlobalFilterIncludesActivity
140
if(
141             request.path().isLike(GLOBAL_FILTER_INCLUDES_ACTIVITY)
142         ) {
143             reply = this.delegation.find(
144                 header,
145                 this.remapFindRequest(
146                     request,
147                     request.path().getPrefix(5).getChild("activity"),
148                     this.plugin.activities.getActivityFilterProperties(
149                         request.path().getPrefix(request.path().size() - 1)
150                     )
151                 )
152             );
153         }
154         // ActivityGroupFilterIncludesActivity
155
else if(
156             request.path().isLike(ACTIVITY_GROUP_FILTER_INCLUDES_ACTIVITY)
157         ) {
158             List JavaDoc filterProperties = new ArrayList JavaDoc();
159             filterProperties.addAll(
160                 Arrays.asList(
161                     this.plugin.activities.getActivityFilterProperties(
162                         request.path().getPrefix(request.path().size() - 1)
163                     )
164                 )
165             );
166             filterProperties.add(
167                 new FilterProperty(
168                     Quantors.THERE_EXISTS,
169                     "p$$activityGroup",
170                     FilterOperators.IS_IN,
171                     new Object JavaDoc[]{request.path().getPrefix(7)}
172                     
173                 )
174             );
175             reply = this.delegation.find(
176                 header,
177                 this.remapFindRequest(
178                     request,
179                     request.path().getPrefix(5).getChild("activity"),
180                     (FilterProperty[])filterProperties.toArray(new FilterProperty[filterProperties.size()])
181                 )
182             );
183         }
184         // PriceLevelHasFilteredAccount
185
else if(
186             request.path().isLike(PRODUCT_PRICE_LEVEL_HAS_FILTERED_ACCOUNT)
187         ) {
188             List JavaDoc filterProperties = new ArrayList JavaDoc();
189             filterProperties.addAll(
190                 Arrays.asList(
191                     this.plugin.accounts.getAccountFilterProperties(
192                         request.path().getPrefix(request.path().size() - 1)
193                     )
194                 )
195             );
196             reply = this.delegation.find(
197                 header,
198                 this.remapFindRequest(
199                     request,
200                     new Path("xri:@openmdx:org.opencrx.kernel.account1/provider").getDescendant(
201                        new String JavaDoc[]{request.path().get(2), "segment", request.path().get(4), "account"}
202                     ),
203                     (FilterProperty[])filterProperties.toArray(new FilterProperty[filterProperties.size()])
204                 )
205             );
206         }
207         // PriceLevelHasFilteredProduct
208
else if(
209             request.path().isLike(PRODUCT_PRICE_LEVEL_HAS_FILTERED_PRODUCT)
210         ) {
211             List JavaDoc filterProperties = new ArrayList JavaDoc();
212             filterProperties.addAll(
213                 Arrays.asList(
214                     this.plugin.products.getProductFilterProperties(
215                         request.path().getPrefix(request.path().size() - 1)
216                     )
217                 )
218             );
219             reply = this.delegation.find(
220                 header,
221                 this.remapFindRequest(
222                     request,
223                     new Path("xri:@openmdx:org.opencrx.kernel.product1/provider").getDescendant(
224                        new String JavaDoc[]{request.path().get(2), "segment", request.path().get(4), "allProduct"}
225                     ),
226                     (FilterProperty[])filterProperties.toArray(new FilterProperty[filterProperties.size()])
227                 )
228             );
229         }
230         // PriceLevelHasAssignedPriceListEntry
231
else if(
232             request.path().isLike(PRODUCT_PRICE_LEVEL_HAS_ASSIGNED_PRICE_LIST_ENTRY)
233         ) {
234             List JavaDoc filterProperties = new ArrayList JavaDoc();
235             filterProperties.add(
236                 new FilterProperty(
237                     Quantors.THERE_EXISTS,
238                     "priceLevel",
239                     FilterOperators.IS_IN,
240                     new Object JavaDoc[]{request.path().getPrefix(7)}
241                     
242                 )
243             );
244             reply = this.delegation.find(
245                 header,
246                 this.remapFindRequest(
247                     request,
248                     new Path("xri:@openmdx:org.opencrx.kernel.product1/provider").getDescendant(
249                        new String JavaDoc[]{request.path().get(2), "segment", request.path().get(4), "priceListEntry"}
250                     ),
251                     (FilterProperty[])filterProperties.toArray(new FilterProperty[filterProperties.size()])
252                 )
253             );
254         }
255         // ResourceContainsWorkReportEntry
256
else if(
257             request.path().isLike(RESOURCE_CONTAINS_WORKREPORT_ENTRY)
258         ) {
259             reply = this.delegation.find(
260                 header,
261                 this.remapFindRequest(
262                     request,
263                     request.path().getPrefix(5).getChild("workReportEntry"),
264                     new FilterProperty[]{
265                         new FilterProperty(
266                             Quantors.THERE_EXISTS,
267                             "resource",
268                             FilterOperators.IS_IN,
269                             new Object JavaDoc[]{request.path().getPrefix(7)}
270                             
271                         )
272                     }
273                 )
274             );
275         }
276         // ActivityContainsWorkReportEntry
277
else if(
278             request.path().isLike(ACTIVITY_CONTAINS_WORKREPORT_ENTRY)
279         ) {
280             reply = this.delegation.find(
281                 header,
282                 this.remapFindRequest(
283                     request,
284                     request.path().getPrefix(5).getChild("workReportEntry"),
285                     new FilterProperty[]{
286                         new FilterProperty(
287                             Quantors.THERE_EXISTS,
288                             "activity",
289                             FilterOperators.IS_IN,
290                             new Object JavaDoc[]{request.path().getPrefix(7)}
291                             
292                         )
293                     }
294                 )
295             );
296         }
297         // ActivityGroupContainsWorkReportEntry
298
else if(
299             request.path().isLike(ACTIVITY_TRACKER_CONTAINS_WORKREPORT_ENTRY) ||
300             request.path().isLike(ACTIVITY_CATEGORY_CONTAINS_WORKREPORT_ENTRY) ||
301             request.path().isLike(ACTIVITY_MILESTONE_CONTAINS_WORKREPORT_ENTRY)
302         ) {
303             reply = this.delegation.find(
304                 header,
305                 this.remapFindRequest(
306                     request,
307                     request.path().getPrefix(5).getChild("workReportEntry"),
308                     new FilterProperty[]{
309                         new FilterProperty(
310                             Quantors.THERE_EXISTS,
311                             "p$$activityGroup",
312                             FilterOperators.IS_IN,
313                             new Object JavaDoc[]{request.path().getPrefix(7)}
314                             
315                         )
316                     }
317                 )
318             );
319         }
320         // CompoundBookingHasBooking
321
else if(request.path().isLike(COMPOUND_BOOKING_HAS_BOOKINGS)) {
322             reply = this.delegation.find(
323                 header,
324                 this.remapFindRequest(
325                     request,
326                     request.path().getPrefix(5).getChild("booking"),
327                     new FilterProperty[]{
328                         new FilterProperty(
329                             Quantors.THERE_EXISTS,
330                             "cb",
331                             FilterOperators.IS_IN,
332                             new Object JavaDoc[]{request.path().getPrefix(7)}
333                         )
334                     }
335                 )
336             );
337         }
338         // DepotPositionHasBooking
339
else if(request.path().isLike(DEPOT_POSITION_HAS_BOOKINGS)) {
340             reply = this.delegation.find(
341                 header,
342                 this.remapFindRequest(
343                     request,
344                     request.path().getPrefix(5).getChild("booking"),
345                     new FilterProperty[]{
346                         new FilterProperty(
347                             Quantors.THERE_EXISTS,
348                             "position",
349                             FilterOperators.IS_IN,
350                             new Object JavaDoc[]{request.path().getPrefix(13)}
351                         )
352                     }
353                 )
354             );
355         }
356         // ClassifierClassifiesTypedElement
357
else if(request.path().isLike(CLASSIFIER_CLASSIFIES_TYPED_ELEMENT)) {
358             reply = this.delegation.find(
359                 header,
360                 this.remapFindRequest(
361                     request,
362                     request.path().getPrefix(5).getChild("element"),
363                     new FilterProperty[]{
364                         new FilterProperty(
365                             Quantors.THERE_EXISTS,
366                             "type",
367                             FilterOperators.IS_IN,
368                             new Object JavaDoc[]{request.path().getPrefix(7)}
369                         )
370                     }
371                 )
372             );
373         }
374         // DepotReportItemHasBookingItem
375
else if(request.path().isLike(DEPOT_REPORT_ITEM_HAS_BOOKING_ITEMS)) {
376             DataproviderObject_1_0 itemPosition = this.plugin.retrieveObjectFromLocal(header, request.path().getParent());
377             reply = this.delegation.find(
378                 header,
379                 this.remapFindRequest(
380                     request,
381                     request.path().getPrefix(request.path().size()-3).getChild("itemBooking"),
382                     new FilterProperty[]{
383                         new FilterProperty(
384                             Quantors.THERE_EXISTS,
385                             "position",
386                             FilterOperators.IS_IN,
387                             new Object JavaDoc[]{itemPosition.values("position").get(0)}
388                         )
389                     }
390                 )
391             );
392         }
393         // DepotContainsDepot
394
else if(request.path().isLike(DEPOT_GROUP_CONTAINS_DEPOTS)) {
395             reply = this.delegation.find(
396                 header,
397                 this.remapFindRequest(
398                     request,
399                     request.path().getPrefix(5).getChild("extent"),
400                     new FilterProperty[]{
401                         new FilterProperty(
402                             Quantors.THERE_EXISTS,
403                             "depotGroup",
404                             FilterOperators.IS_IN,
405                             new Object JavaDoc[]{request.path().getParent()}
406                         ),
407                         new FilterProperty(
408                             Quantors.THERE_EXISTS,
409                             SystemAttributes.OBJECT_IDENTITY,
410                             FilterOperators.IS_LIKE,
411                             new Object JavaDoc[]{request.path().getPrefix(7).getDescendant(new String JavaDoc[]{"depotHolder", ":*", "depot", ":*"})}
412                         )
413                     }
414                 )
415             );
416         }
417         // DepotContainsDepotGroup
418
else if(request.path().isLike(DEPOT_GROUP_CONTAINS_DEPOT_GROUPS)) {
419             reply = this.delegation.find(
420                 header,
421                 this.remapFindRequest(
422                     request,
423                     request.path().getPrefix(request.path().size()-2),
424                     new FilterProperty[]{
425                         new FilterProperty(
426                             Quantors.THERE_EXISTS,
427                             "parent",
428                             FilterOperators.IS_IN,
429                             new Object JavaDoc[]{request.path().getParent()}
430                         )
431                     }
432                 )
433             );
434         }
435         // DepotEntityContainsDepot
436
else if(request.path().isLike(DEPOT_ENTITY_CONTAINS_DEPOTS)) {
437             reply = this.delegation.find(
438                 header,
439                 this.remapFindRequest(
440                     request,
441                     request.path().getPrefix(5).getChild("extent"),
442                     new FilterProperty[]{
443                         new FilterProperty(
444                             Quantors.THERE_EXISTS,
445                             SystemAttributes.OBJECT_IDENTITY,
446                             FilterOperators.IS_LIKE,
447                             new Object JavaDoc[]{request.path().getParent().getDescendant(new String JavaDoc[]{"depotHolder", ":*", "depot", ":*"})}
448                         )
449                     }
450                 )
451             );
452         }
453         // FolderContainsFolder
454
else if(request.path().isLike(FOLDER_CONTAINS_FOLDERS)) {
455             reply = this.delegation.find(
456                 header,
457                 this.remapFindRequest(
458                     request,
459                     request.path().getPrefix(5).getChild("folder"),
460                     new FilterProperty[]{
461                         new FilterProperty(
462                             Quantors.THERE_EXISTS,
463                             "parent",
464                             FilterOperators.IS_IN,
465                             new Object JavaDoc[]{request.path().getParent()}
466                         )
467                     }
468                 )
469             );
470         }
471         // FolderContainsDocument
472
else if(request.path().isLike(FOLDER_CONTAINS_DOCUMENTS)) {
473             reply = this.delegation.find(
474                 header,
475                 this.remapFindRequest(
476                     request,
477                     request.path().getPrefix(5).getChild("document"),
478                     new FilterProperty[]{
479                         new FilterProperty(
480                             Quantors.THERE_EXISTS,
481                             "folder",
482                             FilterOperators.IS_IN,
483                             new Object JavaDoc[]{request.path().getParent()}
484                         )
485                     }
486                 )
487             );
488         }
489         // NamespaceContainsElement
490
else if(request.path().isLike(MODEL_NAMESPACE_CONTAINS_ELEMENTS)) {
491             reply = this.delegation.find(
492                 header,
493                 this.remapFindRequest(
494                     request,
495                     request.path().getPrefix(5).getChild("element"),
496                     new FilterProperty[]{
497                         new FilterProperty(
498                             Quantors.THERE_EXISTS,
499                             "container",
500                             FilterOperators.IS_IN,
501                             new Object JavaDoc[]{request.path().getPrefix(7)}
502                         )
503                     }
504                 )
505             );
506         }
507         // ClassContainsEditableOperation
508
else if(
509             request.path().isLike(MODEL_CLASS_CONTAINS_EDITABLE_OPERATION) ||
510             request.path().getParent().isLike(MODEL_CLASS_CONTAINS_EDITABLE_OPERATION)
511         ) {
512             reply = this.plugin.models.getEditableElements(
513                 request,
514                 "org:opencrx:kernel:model1:Operation",
515                 "org:opencrx:kernel:model1:EditableOperation"
516             );
517         }
518         // ClassContainsEditableAttribute
519
else if(
520             request.path().isLike(MODEL_CLASS_CONTAINS_EDITABLE_ATTRIBUTE) ||
521             request.path().getParent().isLike(MODEL_CLASS_CONTAINS_EDITABLE_ATTRIBUTE)
522         ) {
523             reply = this.plugin.models.getEditableElements(
524                 request,
525                 "org:opencrx:kernel:model1:Attribute",
526                 "org:opencrx:kernel:model1:EditableAttribute"
527             );
528         }
529         // StructureTypeContainsEditableStructureField
530
else if(
531             request.path().isLike(MODEL_STRUCTURE_TYPE_CONTAINS_EDITABLE_STRUCTURE_FIELD) ||
532             request.path().getParent().isLike(MODEL_STRUCTURE_TYPE_CONTAINS_EDITABLE_STRUCTURE_FIELD)
533         ) {
534             reply = this.plugin.models.getEditableElements(
535                 request,
536                 "org:opencrx:kernel:model1:StructureField",
537                 "org:opencrx:kernel:model1:EditableStructureField"
538             );
539         }
540         // OperationContainsEditableParameter
541
else if(
542             request.path().isLike(MODEL_OPERATION_CONTAINS_EDITABLE_PARAMETER) ||
543             request.path().getParent().isLike(MODEL_OPERATION_CONTAINS_EDITABLE_PARAMETER)
544         ) {
545             reply = this.plugin.models.getEditableElements(
546                 request,
547                 "org:opencrx:kernel:model1:Parameter",
548                 "org:opencrx:kernel:model1:EditableParameter"
549             );
550         }
551         // OperationContainsEditableOperationTag
552
else if(
553             request.path().isLike(MODEL_OPERATION_CONTAINS_EDITABLE_OPERATION_TAG) ||
554             request.path().getParent().isLike(MODEL_OPERATION_CONTAINS_EDITABLE_OPERATION_TAG)
555         ) {
556             reply = this.plugin.models.getEditableElements(
557                 request,
558                 "org:opencrx:kernel:model1:Tag",
559                 "org:opencrx:kernel:model1:EditableOperationTag"
560             );
561         }
562         // PackageContainsEditablePackage
563
else if(
564             request.path().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_PACKAGE) ||
565             request.path().getParent().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_PACKAGE)
566         ) {
567             reply = this.plugin.models.getEditableElements(
568                 request,
569                 "org:opencrx:kernel:model1:Package",
570                 "org:opencrx:kernel:model1:EditablePackage"
571             );
572         }
573         // PackageContainsEditableClass
574
else if(
575             request.path().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_CLASS) ||
576             request.path().getParent().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_CLASS)
577         ) {
578             reply = this.plugin.models.getEditableElements(
579                 request,
580                 "org:opencrx:kernel:model1:Class",
581                 "org:opencrx:kernel:model1:EditableClass"
582             );
583         }
584         // PackageContainsEditableStructureType
585
else if(
586             request.path().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_STRUCTURE_TYPE) ||
587             request.path().getParent().isLike(MODEL_PACKAGE_CONTAINS_EDITABLE_STRUCTURE_TYPE)
588         ) {
589             reply = this.plugin.models.getEditableElements(
590                 request,
591                 "org:opencrx:kernel:model1:StructureType",
592                 "org:opencrx:kernel:model1:EditableStructureType"
593             );
594         }
595         // ProductOfferingPositionContainsSelectableItems (Contract)
596
else if(
597             request.path().isLike(CONTRACT_PRODUCT_OFFERING_POSITION_CONTAINS_SELECTABLE_ITEMS) ||
598             request.path().getParent().isLike(CONTRACT_PRODUCT_OFFERING_POSITION_CONTAINS_SELECTABLE_ITEMS)
599         ) {
600             boolean isObjectRetrieval = request.path().size() % 2 == 1;
601             Path referencePath = isObjectRetrieval ? request.path().getParent() : request.path();
602             RequestCollection delegation = new RequestCollection(
603                 header,
604                 this.delegation
605             );
606             DataproviderObject_1_0 offeringPosition = this.plugin.retrieveObjectFromLocal(
607                 header,
608                 referencePath.getParent()
609             );
610             Path contractIdentity = offeringPosition.path().getPrefix(offeringPosition.path().size() - 2);
611             Map JavaDoc selectableItems = MapUtils.orderedMap(new HashMap JavaDoc());
612             Map JavaDoc additionalProductBundles = MapUtils.orderedMap(new HashMap JavaDoc());
613             
614             // Get all product bundle positions having offering position as parent
615
List JavaDoc productBundlePositions = delegation.addFindRequest(
616                 offeringPosition.path().getParent(),
617                 new FilterProperty[]{
618                     new FilterProperty(
619                         Quantors.THERE_EXISTS,
620                         "parentPosition",
621                         FilterOperators.IS_IN,
622                         new Object JavaDoc[]{offeringPosition.path()}
623                     )
624                 },
625                 AttributeSelectors.ALL_ATTRIBUTES,
626                 new AttributeSpecifier[]{
627                     new AttributeSpecifier("lineItemNumber", 0, Orders.ASCENDING)
628                 },
629                 0,
630                 Integer.MAX_VALUE,
631                 Directions.ASCENDING
632             );
633             int itemNumber = 0;
634             for(
635                 Iterator JavaDoc i = productBundlePositions.iterator();
636                 i.hasNext();
637             ) {
638                 DataproviderObject_1_0 productBundlePosition = (DataproviderObject_1_0)i.next();
639                 itemNumber = (itemNumber / 100000 + 1) * 100000;
640                 DataproviderObject selectableItem = this.plugin.contracts.createSelectableProductBundleFromContractPosition(
641                     offeringPosition.path(),
642                     itemNumber,
643                     productBundlePosition
644                 );
645                 selectableItems.put(
646                     selectableItem.path(),
647                     selectableItem
648                 );
649                 
650                 // Get all bundled product positions having product bundle position as parent
651
List JavaDoc bundledProductPositions = delegation.addFindRequest(
652                     productBundlePosition.path().getParent(),
653                     new FilterProperty[]{
654                         new FilterProperty(
655                             Quantors.THERE_EXISTS,
656                             "parentPosition",
657                             FilterOperators.IS_IN,
658                             new Object JavaDoc[]{productBundlePosition.path()}
659                         )
660                     },
661                     AttributeSelectors.ALL_ATTRIBUTES,
662                     new AttributeSpecifier[]{
663                         new AttributeSpecifier("lineItemNumber", 0, Orders.ASCENDING)
664                     },
665                     0,
666                     Integer.MAX_VALUE,
667                     Directions.ASCENDING
668                 );
669                 // SelectableBundledProduct for each BundledProductPosition
670
for(
671                     Iterator JavaDoc j = bundledProductPositions.iterator();
672                     j.hasNext();
673                 ) {
674                     DataproviderObject_1_0 bundledProductPosition = (DataproviderObject_1_0)j.next();
675                     itemNumber = (itemNumber / 100 + 1) * 100;
676                     selectableItem = this.plugin.contracts.createSelectableBundledProductFromContractPosition(
677                         offeringPosition.path(),
678                         itemNumber,
679                         bundledProductPosition
680                     );
681                     selectableItems.put(
682                         selectableItem.path(),
683                         selectableItem
684                     );
685                     
686                     // Get configurations from bundled product position
687
Set JavaDoc selectedConfigurationNames = new HashSet JavaDoc();
688                     List JavaDoc productConfigurations = delegation.addFindRequest(
689                         bundledProductPosition.path().getChild("configuration"),
690                         null,
691                         AttributeSelectors.ALL_ATTRIBUTES,
692                         0,
693                         Integer.MAX_VALUE,
694                         Directions.ASCENDING
695                     );
696                     for(
697                         Iterator JavaDoc k = productConfigurations.iterator();
698                         k.hasNext();
699                     ) {
700                         DataproviderObject_1_0 productConfiguration = (DataproviderObject_1_0)k.next();
701                         itemNumber += 1;
702                         selectableItem = this.plugin.contracts.createSelectableProductConfigurationFromContractPosition(
703                             offeringPosition.path(),
704                             bundledProductPosition.path(),
705                             itemNumber,
706                             productConfiguration
707                         );
708                         selectableItems.put(
709                             selectableItem.path(),
710                             selectableItem
711                         );
712                         selectedConfigurationNames.add(
713                             selectableItem.values("name").get(0)
714                         );
715                     }
716                     // Get configurations from bundled product
717
Path bundledProductIdentity = (Path)bundledProductPosition.values("basedOn").get(0);
718                     productConfigurations = delegation.addFindRequest(
719                         bundledProductIdentity.getChild("configuration"),
720                         null,
721                         AttributeSelectors.ALL_ATTRIBUTES,
722                         0,
723                         Integer.MAX_VALUE,
724                         Directions.ASCENDING
725                     );
726                     for(
727                         Iterator JavaDoc k = productConfigurations.iterator();
728                         k.hasNext();
729                     ) {
730                         DataproviderObject_1_0 productConfiguration = (DataproviderObject_1_0)k.next();
731                         if(!selectedConfigurationNames.contains(productConfiguration.values("name").get(0))) {
732                             itemNumber += 1;
733                             selectableItem = this.plugin.contracts.createSelectableProductConfigurationFromBundledProduct(
734                                 offeringPosition.path(),
735                                 bundledProductPosition.path(),
736                                 itemNumber,
737                                 productConfiguration
738                             );
739                             selectableItems.put(
740                                 selectableItem.path(),
741                                 selectableItem
742                             );
743                         }
744                     }
745                 }
746                 // SelectableBundledProduct for each BundledProduct which is selectable
747
DataproviderObject_1_0 productBundle = this.plugin.retrieveObjectFromLocal(
748                     header,
749                     (Path)productBundlePosition.values("basedOn").get(0)
750                 );
751                 DataproviderObject_1_0 bundleType = this.plugin.retrieveObjectFromLocal(
752                     header,
753                     (Path)productBundle.values("bundleType").get(0)
754                 );
755                 List JavaDoc bundledProducts = delegation.addFindRequest(
756                     bundleType.path().getChild("bundledProduct"),
757                     null,
758                     AttributeSelectors.ALL_ATTRIBUTES,
759                     new AttributeSpecifier[]{
760                         new AttributeSpecifier("itemNumber", 0, Orders.ASCENDING)
761                     },
762                     0,
763                     Integer.MAX_VALUE,
764                     Directions.ASCENDING
765                 );
766                 for(
767                     Iterator JavaDoc j = bundledProducts.iterator();
768                     j.hasNext();
769                 ) {
770                     DataproviderObject_1_0 bundledProduct = (DataproviderObject_1_0)j.next();
771                     if(this.plugin.contracts.allowPositionCreation(contractIdentity, bundledProduct, productBundlePosition.path())) {
772                         itemNumber = (itemNumber / 100 + 1) * 100;
773                         selectableItem = this.plugin.contracts.createSelectableBundledProductFromBundledProduct(
774                             offeringPosition.path(),
775                             productBundlePosition.path(),
776                             itemNumber,
777                             bundledProduct
778                         );
779                     }
780                     selectableItems.put(
781                         selectableItem.path(),
782                         selectableItem
783                     );
784                 }
785                 
786                 // Add selectable product bundle of same type if allowed
787
if(this.plugin.contracts.allowPositionCreation(contractIdentity, productBundle, offeringPosition.path())) {
788                     additionalProductBundles.put(
789                         productBundle.path(),
790                         productBundle
791                     );
792                 }
793             }
794             // Add additional product bundles
795
for(
796                 Iterator JavaDoc i = additionalProductBundles.values().iterator();
797                 i.hasNext();
798             ) {
799                 DataproviderObject_1_0 productBundle = (DataproviderObject_1_0)i.next();
800                 itemNumber = (itemNumber / 100000 + 1) * 100000;
801                 DataproviderObject selectableItem = this.plugin.contracts.createSelectableProductBundleFromProductBundle(
802                     offeringPosition.path(),
803                     itemNumber,
804                     productBundle
805                 );
806                 selectableItems.put(
807                     selectableItem.path(),
808                     selectableItem
809                 );
810             }
811             if(isObjectRetrieval) {
812                 if(selectableItems.containsKey(request.path())) {
813                     reply = new DataproviderReply(
814                         new DataproviderObject(
815                             (DataproviderObject_1_0)selectableItems.get(request.path())
816                         )
817                     );
818                 }
819             }
820             else {
821                 reply = new DataproviderReply(
822                     new ArrayList JavaDoc(selectableItems.values())
823                 );
824                 reply.context(
825                     DataproviderReplyContexts.HAS_MORE
826                 ).set(0, Boolean.FALSE);
827                 reply.context(
828                     DataproviderReplyContexts.TOTAL
829                 ).set(0, new Integer JavaDoc(selectableItems.size()));
830             }
831         }
832         return reply;
833     }
834     
835     //-------------------------------------------------------------------------
836
// Patterns for derived find requests
837
public static final Path COMPOUND_BOOKING_HAS_BOOKINGS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/cb/:*/booking");
838     public static final Path DEPOT_POSITION_HAS_BOOKINGS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/position/:*/booking");
839     public static final Path CLASSIFIER_CLASSIFIES_TYPED_ELEMENT = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/classifies");
840     public static final Path DEPOT_REPORT_ITEM_HAS_BOOKING_ITEMS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotHolder/:*/depot/:*/report/:*/itemPosition/:*/itemBooking");
841     public static final Path DEPOT_GROUP_CONTAINS_DEPOTS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotGroup/:*/depot");
842     public static final Path DEPOT_GROUP_CONTAINS_DEPOT_GROUPS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depotGroup/:*/depotGroup");
843     public static final Path DEPOT_ENTITY_CONTAINS_DEPOTS = new Path("xri:@openmdx:org.opencrx.kernel.depot1/provider/:*/segment/:*/entity/:*/depot");
844     public static final Path FOLDER_CONTAINS_FOLDERS = new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*/folder/:*/folder");
845     public static final Path FOLDER_CONTAINS_DOCUMENTS = new Path("xri:@openmdx:org.opencrx.kernel.document1/provider/:*/segment/:*/folder/:*/document");
846     public static final Path CONTRACT_PRODUCT_OFFERING_POSITION_CONTAINS_SELECTABLE_ITEMS = new Path("xri:@openmdx:org.opencrx.kernel.contract1/provider/:*/segment/:*/:*/:*/position/:*/selectableItem");
847     public static final Path MODEL_NAMESPACE_CONTAINS_ELEMENTS = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/content");
848     public static final Path MODEL_CLASS_CONTAINS_EDITABLE_OPERATION = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/operation");
849     public static final Path MODEL_CLASS_CONTAINS_EDITABLE_ATTRIBUTE = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/attribute");
850     public static final Path MODEL_STRUCTURE_TYPE_CONTAINS_EDITABLE_STRUCTURE_FIELD = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/field");
851     public static final Path MODEL_OPERATION_CONTAINS_EDITABLE_PARAMETER = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/parameter");
852     public static final Path MODEL_OPERATION_CONTAINS_EDITABLE_OPERATION_TAG = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/operationTag");
853     public static final Path MODEL_PACKAGE_CONTAINS_EDITABLE_PACKAGE = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/package");
854     public static final Path MODEL_PACKAGE_CONTAINS_EDITABLE_CLASS = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/class");
855     public static final Path MODEL_PACKAGE_CONTAINS_EDITABLE_STRUCTURE_TYPE = new Path("xri:@openmdx:org.opencrx.kernel.model1/provider/:*/segment/:*/element/:*/structureType");
856     public static final Path GLOBAL_FILTER_INCLUDES_ACTIVITY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityFilter/:*/filteredActivity");
857     public static final Path ACTIVITY_GROUP_FILTER_INCLUDES_ACTIVITY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/:*/:*/activityFilter/:*/filteredActivity");
858     public static final Path RESOURCE_CONTAINS_WORKREPORT_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/resource/:*/workReportEntry");
859     public static final Path ACTIVITY_CONTAINS_WORKREPORT_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activity/:*/workReportEntry");
860     public static final Path ACTIVITY_TRACKER_CONTAINS_WORKREPORT_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityTracker/:*/workReportEntry");
861     public static final Path ACTIVITY_CATEGORY_CONTAINS_WORKREPORT_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityCategory/:*/workReportEntry");
862     public static final Path ACTIVITY_MILESTONE_CONTAINS_WORKREPORT_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.activity1/provider/:*/segment/:*/activityMilestone/:*/workReportEntry");
863     public static final Path PRODUCT_PRICE_LEVEL_HAS_FILTERED_ACCOUNT = new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/priceLevel/:*/filteredAccount");
864     public static final Path PRODUCT_PRICE_LEVEL_HAS_FILTERED_PRODUCT = new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/priceLevel/:*/filteredProduct");
865     public static final Path PRODUCT_PRICE_LEVEL_HAS_ASSIGNED_PRICE_LIST_ENTRY = new Path("xri:@openmdx:org.opencrx.kernel.product1/provider/:*/segment/:*/priceLevel/:*/priceListEntry");
866     
867     private final Model_1_0 model;
868     private final OpenCrxKernel_1 plugin;
869     private final Layer_1_0 delegation;
870     private final RefPackage_1_0 rootPkg;
871     
872         
873 }
874
875 //--- End of File -----------------------------------------------------------
876
Popular Tags