02-18-2013 04:11 AM
package com.tecnausa.meconecto;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
import org.alfresco.web.bean.generator.BaseComponentGenerator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ListOfValuesQueryConstraint extends ListOfValuesConstraint implements Serializable{
@SuppressWarnings("unused")
private static Log logger = LogFactory.getLog(BaseComponentGenerator.class);
private static final long serialVersionUID=1;
private List<String> allowedLabels;
@SuppressWarnings("unchecked")
public void setAllowedValues(List allowedValues) {}
public void setCaseSensitive(boolean caseSensitive) {}
public void initialize() {
super.setCaseSensitive(false);
this.loadDB();
}
public List<String> getAllowedLabels() {
return this.allowedLabels;
}
public void setAllowedLabels(List<String> allowedLabels) {
this.allowedLabels=allowedLabels;
}
public List<SelectItem> getSelectItemList() {
List<SelectItem> result = new ArrayList<SelectItem>(this.getAllowedValues().size());
for(int i=0;i<this.getAllowedValues().size();i++) {
result.add(new SelectItem((Object)this.getAllowedValues().get(i),this.allowedLabels.get(i)));
}
return result;
}
protected void loadDB() {
/*
String driverName = "org.postgresql.Driver";
String serverName = "localhost";
String mydatabase = "alfresco";
String username = "alfresco";
String password = "admin";
String port = "5432";
*/
List<String> av = new ArrayList<String>();
List<String> al=new ArrayList<String>();
av.add("av1");
av.add("av2");
av.add("av3");
/*
try {
Connection connection = null;
Class.forName(driverName);
String url = "jdbcsmileyostgresql://" + serverName + ":"+ port + "/" + mydatabase;
connection = DriverManager.getConnection(url, username, password);
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select mi_id from t_equipos"smiley;
while (rs.next()) {
av.add(rs.getString("JMBG"smiley);
}
}
catch (Exception e) {}
*/
}
}
……
<constraints>
<constraint name="dlexample:l01" type="LIST">
<parameter name="allowedValues">
<list>
<value>Equipo de red</value>
<value>Impresora</value>
<value>Ordenador PC</value>
</list>
</parameter>
</constraint>
<constraint name="dlexample:l02" type="com.tecnausa.meconecto.ListOfValuesQueryConstraint"></constraint>
</constraints>
<types>
<type name="dlexample:book">
….
<property name="dlexample:lista1">
<title>lista1</title>
<type>d:text</type>
<constraints>
<constraint ref="dlexample:l01" />
</constraints>
</property>
….
02-18-2013 05:56 AM
02-18-2013 06:35 AM
<parameter name="allowedValues" type="com.tecnausa.meconecto.ListOfValuesQueryConstraint">
<list>
</list>
</parameter>
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.