05-04-2010 02:57 AM
> alfresco
> extension
> web-client-config-custom.xml
> META-INF
> faces-config.xml
> MANIFEST.MF
> org
> alfresco
> solidcam
> CreateScPostDialog.class
<%–
–%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<f:verbatim>
<script type="text/javascript" src="<%=request.getContextPath()%>/scripts/validation.js"> </script>
<script type="text/javascript">
var finishButtonPressed = false;
window.onload = pageLoaded;
function pageLoaded()
{
document.getElementById("dialog:dialog-body:name").focus();
document.getElementById("dialog").onsubmit = validateDialog;
document.getElementById("dialog:finish-button").onclick = function() {finishButtonPressed = true; clear_dialog();}
checkButtonState();
}
function checkButtonState()
{
if (document.getElementById("dialog:dialog-body:name").value.length == 0 )
{
document.getElementById("dialog:finish-button").disabled = true;
}
else
{
document.getElementById("dialog:finish-button").disabled = false;
}
}
</script>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr>
<td colspan="3" class="wizardSectionHeading">
</f:verbatim>
<h:outputText value="#{msg.properties}" />
<f:verbatim>
</td>
</tr>
<tr>
<td align="middle">
</f:verbatim>
<h:graphicImage value="/images/icons/required_field.gif" alt="#{msg.required_field}" />
<f:verbatim>
</td>
<td>
</f:verbatim>
<h:outputText value="#{msg.name}:" />
<f:verbatim>
</td>
<td width="85%">
</f:verbatim>
<h:inputText id="name" value="#{DialogManager.bean.name}" size="35" maxlength="1024"
onkeyup="javascript:checkButtonState();" onchange="javascript:checkButtonState();" />
<f:verbatim>
</td>
</tr>
<tr>
<td></td>
<td>
</f:verbatim>
<h:outputText value="#{msg.title}:" />
<f:verbatim>
</td>
<td>
</f:verbatim>
<h:inputText id="title" value="#{DialogManager.bean.title}" size="35" maxlength="1024" />
<f:verbatim>
</td>
</tr>
<tr>
<td></td>
<td>
</f:verbatim>
<h:outputText value="#{msg.description}:" />
<f:verbatim>
</td>
<td>
</f:verbatim>
<h:inputText id="description" value="#{DialogManager.bean.description}" size="35" maxlength="1024" />
<f:verbatim>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
<td></f:verbatim><h:outputText id="text12" value="Machine Type:" /><f:verbatim></td>
<td></f:verbatim><h:selectOneMenu id="machineType" value="#{CreateScPostDialog.machineType}">
<f:selectItems value="#{CreateScPostDialog.machineTypes}" />
</h:selectOneMenu><f:verbatim></td>
</tr>
<tr>
<td></td>
<td></f:verbatim><h:outputText id="text13" value="Machine Name:" /><f:verbatim></td>
<td></f:verbatim><h:selectOneMenu id="machineName" value="#{CreateScPostDialog.machineName}">
<f:selectItems value="#{CreateScPostDialog.machineNames}" />
</h:selectOneMenu><f:verbatim></td>
</tr>
<tr>
<td></td>
<td></f:verbatim><h:outputText id="text14" value="Machine Controller:" /><f:verbatim></td>
<td></f:verbatim><h:selectOneMenu id="machineController" value="#{CreateScPostDialog.machineController}">
<f:selectItems value="#{CreateScPostDialog.machineControllers}" />
</h:selectOneMenu><f:verbatim></td>
</tr>
<tr>
<td></td>
<td></f:verbatim><h:outputText id="text15" value="SolidCAM Version:" /><f:verbatim></td>
<td></f:verbatim><h:selectOneMenu id="solidCamVersion" value="#{CreateScPostDialog.solidCamVersion}">
<f:selectItems value="#{CreateScPostDialog.solidCamVersions}" />
</h:selectOneMenu><f:verbatim></td>
</tr>
</table>
</f:verbatim>
<alfresco-config>
<config>
<actions>
<!– Launch Create post Dialog –>
<action id="create_sc_post">
<label>Create Post</label>
<image>/images/icons/create_space.gif</image>
<action>dialog:CreateScPost</action>
</action>
<!– Add action to more actions menu for each space –>
<action-group id="browse_create_menu">
<action idref="create_sc_post" />
</action-group>
</actions>
<dialogs>
<dialog name="CreateScPost" page="/jsp/extension/create-sc-post.jsp" managed-bean="CreateScPostDialog"
icon="/images/icons/create_space_large.gif" title="Create Post"
description="Create a post" />
</dialogs>
</config>
face
</alfresco-config>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<!– *************************************************************** –>
<!– Empty JSF config file to prevent errors being thrown during JSF –>
<!– initialisation. Overwrite this file with your custom version. –>
<!– *************************************************************** –>
<managed-bean>
<description>
The bean that backs up the Create post Dialog
</description>
<managed-bean-name>CreateScPostDialog</managed-bean-name>
<managed-bean-class>org.alfresco.solidcam.CreateScPostDialog</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>nodeService</property-name>
<value>#{NodeService}</value>
</managed-property>
<managed-property>
<property-name>fileFolderService</property-name>
<value>#{FileFolderService}</value>
</managed-property>
<managed-property>
<property-name>searchService</property-name>
<value>#{SearchService}</value>
</managed-property>
<managed-property>
<property-name>navigator</property-name>
<value>#{NavigationBean}</value>
</managed-property>
<managed-property>
<property-name>browseBean</property-name>
<value>#{BrowseBean}</value>
</managed-property>
<managed-property>
<property-name>namespaceService</property-name>
<value>#{NamespaceService}</value>
</managed-property>
<managed-property>
<property-name>contentService</property-name>
<value>#{ContentService}</value>
</managed-property>
<managed-property>
<property-name>dictionaryService</property-name>
<value>#{DictionaryService}</value>
</managed-property>
</managed-bean>
</faces-config>
package org.alfresco.solidcam;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Iterator;
import java.util.Collection;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
//import org.alfresco.service.cmr.security;
import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.search.CategoryService.Depth;
import org.alfresco.service.namespace.DynamicNamespacePrefixResolver;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.repo.component.UICharsetSelector;
import org.alfresco.web.ui.repo.component.UICategorySelector;
/**
* Dialog bean to create a post
* @author hagit
*/
public class CreateScPostDialog extends BaseDialogBean
{
//private static final long serialVersionUID = 4659583264588102372L;???
// ——————————————————————————
// Wizard implementation
protected String name;
protected String title;
protected String description;
protected String machineType;
protected String machineName;
protected String machineController;
protected String solidCamVersion;
//protected List<NodeRef> categories = new ArrayList<NodeRef>();
private List<SelectItem> machineTypes;
private List<SelectItem> machineNames;
private List<SelectItem> machineControllers;
private List<SelectItem> solidCamVersions;
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
//String postIcon = "space-icon-default";
String postIcon = "space-icon-custom";
String newSpaceId = null;
// copy the selected space and update the name, description and icon
// Get the refernce for the Post Template (we have to look for it using the search mechanism
DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
namespacePrefixResolver.registerNamespace(NamespaceService.APP_MODEL_PREFIX, NamespaceService.APP_MODEL_1_0_URI);
//String xpath = Application.getRootPath(FacesContext.getCurrentInstance()) + "/" +
// Application.getGlossaryFolderName(FacesContext.getCurrentInstance()) + "/" +
// Application.getSpaceTemplatesFolderName(FacesContext.getCurrentInstance())+ "/";
String xpath = "/app:company_home/app:dictionary/app:space_templates/*";
//NodeRef templateNode = rootNode.getNode(xpath);
NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef());
List<NodeRef> templateNodeList = this.getSearchService().selectNodes(
rootNodeRef,
xpath, null, namespacePrefixResolver, false);
//if (templateNodeList.size() == 1)
//{
// get the first item in the list as we from test above there is only one!
NodeRef templateNode = templateNodeList.get(0);
//}
//NodeRef sourceNode = new NodeRef(Repository.getStoreRef(), "Company Home/Data Dictionary/Space Templates/Post Template");
NodeRef curNode;
String nodeName;
for (int i = 0; i < templateNodeList.size(); ++i)
{
curNode = templateNodeList.get(i);
nodeName = (String)this.getNodeService().getProperty(curNode, ContentModel.PROP_NAME);
System.out.println("Name= " + nodeName);
if (nodeName.equals("PostTemplate"))
{
System.out.println("Post template found");
templateNode = curNode;
}
}
NodeRef parentSpace = new NodeRef(Repository.getStoreRef(), this.navigator.getCurrentNodeId());
// copy from the template
NodeRef copiedNode = this.getFileFolderService().copy(templateNode, parentSpace, this.name).getNodeRef();
// also need to set the new title, description and icon properties
this.getNodeService().setProperty(copiedNode, ContentModel.PROP_TITLE, this.title);
this.getNodeService().setProperty(copiedNode, ContentModel.PROP_DESCRIPTION, this.description);
this.getNodeService().setProperty(copiedNode, ApplicationModel.PROP_ICON, postIcon );
// because of a bug in alfresco I need to set the permissions for the post
// note that geting the getPermissionService from Dialog bean is not straightforward
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPermissionService().
setPermission(copiedNode, "admin", "Coordinator", true);
newSpaceId = copiedNode.getId();
//if (logger.isDebugEnabled())
// logger.debug("Copied template space with id of " + sourceNode.getId() + " to " + this.name);
System.out.println("Machine Name: " + this.machineName);
// Now add all the categories
ArrayList<NodeRef> categories = new ArrayList<NodeRef>(5);
NodeRef categoryeNode;
if (this.machineType != null && this.machineType.length() > 0)
{
categoryeNode = new NodeRef(Repository.getStoreRef(), this.machineType);
categories.add(categoryeNode);
}
if (this.machineName != null && this.machineName.length() > 0)
{
categoryeNode = new NodeRef(Repository.getStoreRef(), this.machineName);
categories.add(categoryeNode);
}
if (this.machineController != null && this.machineController.length() > 0)
{
categoryeNode = new NodeRef(Repository.getStoreRef(), this.machineController);
categories.add(categoryeNode);
}
if (this.solidCamVersion != null && this.solidCamVersion.length() > 0)
{
categoryeNode = new NodeRef(Repository.getStoreRef(), this.solidCamVersion);
categories.add(categoryeNode);
}
this.getNodeService().setProperty(copiedNode, ContentModel.PROP_CATEGORIES, categories);
return outcome;
}
/**
* @return Returns the name.
*/
public String getName()
{
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name)
{
this.name = name.trim();
}
/**
* @return Returns the title.
*/
public String getTitle()
{
return title;
}
/**
* @param title The title to set.
*/
public void setTitle(String title)
{
this.title = title;
}
/**
* @return Returns the description.
*/
public String getDescription()
{
return description;
}
/**
* @param description The description to set.
*/
public void setDescription(String description)
{
this.description = description;
}
/**
* @return Returns the machineType currently selected
*/
public String getMachineType()
{
if (machineType == null || machineType.length() == 0)
{
// if not configured, set to a sensible default for most character sets
//machineType = "Milling";
System.out.println("CreateScPost: Machine Type not set");
}
else
System.out.println("CreateScPost: Get Machine Type " + machineType);
return machineType;
}
/**
* @param machineType the document's machineType
*/
public void setMachineType(String machineType)
{
this.machineType = machineType;
}
public List<SelectItem> getMachineTypes()
{
FacesContext context = FacesContext.getCurrentInstance();
if (this.machineTypes == null)
this.machineTypes = new ArrayList<SelectItem>(20);
else
this.machineTypes.clear(); // We may have to improve if it takes too much time to rebuild the list
Collection<ChildAssociationRef> childRefs = Repository.getServiceRegistry(context).getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
NodeRef machineTypeCatRef = null;
Iterator<ChildAssociationRef> iter = childRefs.iterator();
String catName;
int i;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
System.out.println("assocRef " + assocRef);
machineTypeCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(machineTypeCatRef, ContentModel.PROP_NAME);
System.out.println("catName " + catName);
if (catName.equals("Machine Type"))
break;
}
if (machineTypeCatRef != null && i < childRefs.size())
{
this.machineTypes.add(new SelectItem("", ""));
childRefs = Repository.getServiceRegistry(context).getCategoryService().
getChildren(machineTypeCatRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE);
iter = childRefs.iterator();
NodeRef curCatRef = null;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
curCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(curCatRef, ContentModel.PROP_NAME);
System.out.println("SSS catName " + catName + " Id= " + curCatRef.getId());
this.machineTypes.add(new SelectItem(curCatRef.getId(), catName));
}
}
else
System.out.println("CreateScPost: Machine type category is not found in system");
return this.machineTypes;
// return UICharsetSelector.getCharsetEncodingList();
}
/**
* @return Returns the machineName currently selected
*/
public String getMachineName()
{
if (machineName == null || machineName.length() == 0)
{
// if not configured, set to a sensible default for most character sets
//machineName = "Milling";
System.out.println("CreateScPost: Machine Name not set");
}
else
System.out.println("SSSSSS: Machine Name is set");
return machineName;
}
/**
* @param machineName the document's machineName
*/
public void setMachineName(String machineName)
{
this.machineName = machineName;
}
public List<SelectItem> getMachineNames()
{
FacesContext context = FacesContext.getCurrentInstance();
if (this.machineNames == null)
this.machineNames = new ArrayList<SelectItem>(100);
else
this.machineNames.clear(); // We may have to improve if it takes too much time to rebuild the list
Collection<ChildAssociationRef> childRefs = Repository.getServiceRegistry(context).getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
//System.out.println(" getMachineNames childRefs " + childRefs.size());
NodeRef machineNameCatRef = null;
Iterator<ChildAssociationRef> iter = childRefs.iterator();
String catName;
int i;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
machineNameCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(machineNameCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName);
if (catName.equals("Machine Name"))
break;
}
if (machineNameCatRef != null && i < childRefs.size())
{
this.machineNames.add(new SelectItem("", ""));
childRefs = Repository.getServiceRegistry(context).getCategoryService().
getChildren(machineNameCatRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE);
iter = childRefs.iterator();
NodeRef curCatRef = null;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
curCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(curCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName + " Id= " + curCatRef.getId());
this.machineNames.add(new SelectItem(curCatRef.getId(), catName));
}
}
else
System.out.println("CreateScPost: Machine Names do not exist in categories");
return this.machineNames;
}
/**
* @return Returns the machineController currently selected
*/
public String getMachineController()
{
if (machineController == null || machineController.length() == 0)
{
// if not configured, set to a sensible default for most character sets
//machineController = "Milling";
System.out.println("CreateScPost: Machine Controller not set");
}
else
System.out.println("SSSSSSDS Machine Controller is set");
return machineController;
}
/**
* @param machineController the document's machineController
*/
public void setMachineController(String machineController)
{
this.machineController = machineController;
}
public List<SelectItem> getMachineControllers()
{
FacesContext context = FacesContext.getCurrentInstance();
if (this.machineControllers == null)
this.machineControllers = new ArrayList<SelectItem>(100);
else
this.machineControllers.clear(); // We may have to improve if it takes too much time to rebuild the list
System.out.println("SSSSSSSSSSSSSSS GetMachineControllers");
// getCategories(this.machineControllers, "Machine Controller");
Collection<ChildAssociationRef> childRefs = Repository.getServiceRegistry(context).getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
//System.out.println(" getMachineControllers childRefs " + childRefs.size());
NodeRef machineControllerCatRef = null;
Iterator<ChildAssociationRef> iter = childRefs.iterator();
String catName;
int i;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
machineControllerCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(machineControllerCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName);
if (catName.equals("Machine Controller"))
break;
}
if (machineControllerCatRef != null && i < childRefs.size())
{
this.machineControllers.add(new SelectItem("", ""));
childRefs = Repository.getServiceRegistry(context).getCategoryService().
getChildren(machineControllerCatRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE);
iter = childRefs.iterator();
NodeRef curCatRef = null;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
curCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(curCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName + " Id= " + curCatRef.getId());
// example wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
this.machineControllers.add(new SelectItem(curCatRef.getId(), catName));
}
}
else
System.out.println("CreateScPost: Machine Controllers not defined in systems");
return this.machineControllers;
}
// ———————–
public String getSolidCamVersion()
{
if (solidCamVersion == null || solidCamVersion.length() == 0)
{
// if not configured, set to a sensible default for most character sets
//machineController = "Milling";
System.out.println("CreateScPost: SolidCAM Version not set");
}
else
System.out.println("SSSSSSDS SolidCAM Version is set");
return solidCamVersion;
}
/**
* @param machineController the document's machineController
*/
public void setSolidCamVersion(String solidCamVersion)
{
this.solidCamVersion = solidCamVersion;
}
public List<SelectItem> getSolidCamVersions()
{
FacesContext context = FacesContext.getCurrentInstance();
if (this.solidCamVersions == null)
this.solidCamVersions = new ArrayList<SelectItem>(50);
else
this.solidCamVersions.clear(); // We may have to improve if it takes too much time to rebuild the list
System.out.println("SSSSSSSSSSSSSSS GetSolidCamVersions");
// getCategories(this.machineControllers, "Machine Controller");
Collection<ChildAssociationRef> childRefs = Repository.getServiceRegistry(context).getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
//System.out.println(" getMachineControllers childRefs " + childRefs.size());
NodeRef solidCamVersionCatRef = null;
Iterator<ChildAssociationRef> iter = childRefs.iterator();
String catName;
int i;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
solidCamVersionCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(solidCamVersionCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName);
if (catName.equals("SolidCAM Version"))
break;
}
if (solidCamVersionCatRef != null && i < childRefs.size())
{
this.solidCamVersions.add(new SelectItem("", ""));
childRefs = Repository.getServiceRegistry(context).getCategoryService().
getChildren(solidCamVersionCatRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.ANY);
iter = childRefs.iterator();
NodeRef curCatRef = null;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
curCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(curCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName + " Id= " + curCatRef.getId());
// example wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
this.solidCamVersions.add(new SelectItem(curCatRef.getId(), catName));
}
}
else
System.out.println("CreateScPost: solidCam Versions not defined in systems");
return this.solidCamVersions;
}
// ———————–
private void getCategories(ArrayList<SelectItem> catList, String catTypeName)
{
FacesContext context = FacesContext.getCurrentInstance();
Collection<ChildAssociationRef> childRefs = Repository.getServiceRegistry(context).getCategoryService().getCategories(Repository.getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, Depth.IMMEDIATE);
//System.out.println(" getMachineControllers childRefs " + childRefs.size());
NodeRef catRef = null;
Iterator<ChildAssociationRef> iter = childRefs.iterator();
String catName;
int i;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
catRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(catRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName);
if (catName.equals(catTypeName))
break;
}
if (catRef != null && i < childRefs.size())
{
this.machineControllers.add(new SelectItem("", ""));
childRefs = Repository.getServiceRegistry(context).getCategoryService().
getChildren(catRef, CategoryService.Mode.SUB_CATEGORIES, CategoryService.Depth.IMMEDIATE);
iter = childRefs.iterator();
NodeRef curCatRef = null;
for (i = 0; i < childRefs.size(); i++)
{
ChildAssociationRef assocRef = iter.next();
curCatRef = assocRef.getChildRef();
catName = (String)this.getNodeService().getProperty(curCatRef, ContentModel.PROP_NAME);
System.out.println(" catName " + catName + " Id= " + curCatRef.getId());
// example wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
this.machineControllers.add(new SelectItem(curCatRef.getId(), catName));
}
}
else
System.out.println("CreateScPost: " + catTypeName + " not defined in systems");
}
}
05-09-2010 03:19 AM
07-08-2010 05:38 AM
07-08-2010 06:16 AM
07-08-2010 08:35 AM
<alfresco-config>
<!– Add custom dialog –>
<config>
<actions>
<!– Launch Clinical Documents Search Dialog –>
<action id="search_StoryLevel">
<label>Search Story Level</label>
<action>dialog:SearchStoryLevel</action>
</action>
<action-group id="navigator_actions">
<action idref="search_StoryLevel"/>
</action-group>
</actions>
</config>
<config>
<dialogs>
<dialog name="SearchStoryLevel"
page = "/jsp/search-StoryLevel.jsp"
managed-bean="SearchStoryLevelDialog"
title="Search for Story Level"
description="Returns list of Story Level">
<buttons>
<button id="searchStoryLevel_new"
label="New search"
action="#{DialogManager.bean.newSearch}"
disabled="#{DialogManager.bean.newSearchDisabled}"
/>
</buttons>
</dialog>
</dialogs>
</config>
</alfresco-config>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<h:panelGroup rendered="#{DialogManager.bean.searchFinished == false }">
<h:outputText value="Enter serach terms then click \"Search\": "/>
<h:inputText size="100" value="#{DialogManager.bean.searchTerms}" />
</h:panelGroup>
<h:panelGroup rendered="#{DialogManager.bean.searchFinished == true }">
<h:outputText value="Serach terms: "/>
<h:outputText value="#{DialogManager.bean.searchTerms}" style="font-weight:bold"/>
<f:verbatim><BR><BR></f:verbatim>
<h:dataTable var="node" value="#{DialogManager.bean.sortedNodes}" border="1" cellpadding="10" style="vertical-align:top; ">
<h:column>
<h:outputLink value="/alfresco/#{node.url}" target="_blank">
<h:outputText value="#{node.name}" />
</h:outputLink>
</h:column>
</h:dataTable>
</h:panelGroup>
07-08-2010 10:19 AM
07-08-2010 04:00 PM
07-12-2010 01:44 AM
package edu.fccc.sample;
import javax.faces.context.FacesContext;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.web.app.servlet.DownloadContentServlet;
public class SearchStoryLevelDialog extends BaseDialogBean{
private static final long serialVersionUID = 1L;
private String searchTerms;
private boolean searchFinished;
private java.util.List<Node> sortedNodes;
public void init(java.util.Map<String,String> parameters)
{
super.init(parameters);
searchFinished = false;
}
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
startSearch();
searchFinished = true;
return "do nothing";
}
public boolean getFinishButtonDisabled()
{
return searchFinished;
}
public boolean getNewSearchDisabled(){
return !searchFinished;
}
public String getFinishButtonLabel()
{
return "Search";
}
public String getCancelButtonLabel()
{
return "Finish";
}
//main method: performs search and stores result to sortedNodes
public void startSearch(){
sortedNodes = new java.util.ArrayList<Node>();
SearchParameters searchParameters = new SearchParameters();
searchParameters.addStore(new StoreRef("workspace", "SpacesStore"));
this.getSearchService();
searchParameters.setLanguage(SearchService.LANGUAGE_LUCENE);
//I only searched for documents with certain custom aspect; modify query to fit your model
String aspect= " +ASPECT:\"{custom.model}StoryLevel\"";
String text = " +TEXT:\""+ searchTerms.trim() +"\"";
searchParameters.setQuery(aspect + text);
ResultSet reports = this.getSearchService().query(searchParameters);
for (ResultSetRow row: reports){
sortedNodes.add(new Node(row));
}
}
// called when New Search button clicked – resets dialog
public void newSearch(){
init(new java.util.HashMap<String, String>());
}
public String getSearchTerms() {
return searchTerms;
}
public void setSearchTerms(String searchTerms) {
this.searchTerms = searchTerms;
}
public java.util.List<Node> getSortedNodes() {
return sortedNodes;
}
public void setSortedNodes(java.util.List<Node> sortedNodes) {
this.sortedNodes = sortedNodes;
}
public boolean isSearchFinished() {
return searchFinished;
}
public void setSearchFinished(boolean searchFinished) {
this.searchFinished = searchFinished;
}
public class Node{
String name;
String url;
public Node (ResultSetRow row){
try {
name = row.getValue(QName.createQName("{http://www.alfresco.org/model/content/1.0}name")).toString();
}catch (Exception e){}
try {
url = DownloadContentServlet.generateBrowserURL(row.getNodeRef(), name);
}catch (Exception e){}
//add more code
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
}
07-12-2010 01:58 AM
07-12-2010 04:08 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.