venice-dynamo-rewrite/venice-data/scripts/sidebox_config.js
2003-06-01 10:10:54 +00:00

72 lines
2.8 KiB
JavaScript

// The contents of this file are subject to the Mozilla Public License Version 1.1
// (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
//
// Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
// WARRANTY OF ANY KIND, either express or implied. See the License for the specific
// language governing rights and limitations under the License.
//
// The Original Code is the Venice Web Communities System.
//
// The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
// Copyright (C) 2003 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
//
// Contributor(s):
importPackage(java.util);
importClass(Packages.com.silverwrist.dynamo.Namespaces);
importPackage(Packages.com.silverwrist.dynamo.iface);
importPackage(Packages.com.silverwrist.dynamo.util);
importClass(Packages.com.silverwrist.venice.VeniceNamespaces);
importPackage(Packages.com.silverwrist.venice.content);
importPackage(Packages.com.silverwrist.venice.iface);
importPackage(Packages.com.silverwrist.venice.sidebox);
req = bsf.lookupBean("request"); // get request
rhelp = bsf.lookupBean("request_help"); // get request helper
user = vlib.getUser(req); // get user
// Get the list of the user's sideboxes.
sideboxes = vcast.querySideboxService(req_help.getRequestObject(Namespaces.DYNAMO_OBJECT_NAMESPACE,"venice-sidebox"));
list = sideboxes.getSideboxDescriptors(user,VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top",null);
// Create a set that contains all the IDs of the sideboxes.
matchset = new HashSet();
it = list.iterator();
while (it.hasNext())
{ // add the IDs to the set
d = vcast.toSideboxDescriptor(it.next());
matchset.add(cast.toIntegerObject(d.getID()));
} // end while
// Get the list of all possible sideboxes.
all_list = sideboxes.getAllSideboxDescriptors(VeniceNamespaces.SIDEBOX_CONTEXT_NAMESPACE,"top");
// Use that list and the match set to generate the "not list".
not_list = null;
if (list.size()==all_list.size())
not_list = Collections.EMPTY_LIST;
else if (list.size()==0)
not_list = all_list;
else
{ // need to generate the "not list"
not_list = new ArrayList(all_list.size());
it = all_list.iterator();
while (it.hasNext())
{ // check the list...
d = vcast.toSideboxDescriptor(it.next());
if (!(matchset.contains(cast.toIntegerObject(d.getID()))))
not_list.add(d);
} // end while
} // end else
// Generate the output object.
rc = new VelocityView("Your Sidebox Configuration: Front Page","sidebox_config.vm");
rc.setParameter("list",list);
rc.setParameter("notlist",not_list);
dynamo.scriptOutput(rc);