public org_uengine_kernel_RoleMappingInput(){
super(RoleMapping.class);
}
public Object createValueFromHTTPRequest(Map req, String section, String name, Object oldValue) {
RoleMapping nullValue = //a command that will do nothing
new RoleMapping(){
public boolean doCommand(ProcessInstance instance, String variableKey) throws Exception {
return true;
}
public String getEndpoint() {
return null;
}
public String toString(){
return "<empty>";
}
};
if(req==null || !req.containsKey(createNameAttribute(section, name))) return nullValue;
String value = TextInput.createStringFromHTTPRequest(req, section, name);
if(!UEngineUtil.isNotEmpty(value)) return nullValue;
String [] values = value.split(";");
String userName = TextInput.createStringFromHTTPRequest(req, section, name + "_display");
if(!UEngineUtil.isNotEmpty(userName)) return nullValue;
String [] userNames = userName.split(";");
String gender = TextInput.createStringFromHTTPRequest(req, section, name + "_gender");
if(!UEngineUtil.isNotEmpty(gender)) return nullValue;
String [] genders = gender.split(";");
String birthday = TextInput.createStringFromHTTPRequest(req, section, name + "_birthday");
String [] birthdays = new String[]{};
if(UEngineUtil.isNotEmpty(birthday))
birthdays = birthday.split(";");
if(values.length > 0){
RoleMapping roleMapping = RoleMapping.create();
for(int i=0; i<values.length; i++){
roleMapping.setEndpoint(values[i]);
roleMapping.setResourceName(userNames[i]);
roleMapping.setMale("true".equals(genders[i]));
try{
Date birthdayInDate = new Date(Long.parseLong(birthdays[i]));
roleMapping.setBirthday(birthdayInDate);
}catch(Exception e){
}
if(i < (values.length-1))
roleMapping.moveToAdd();
}
roleMapping.beforeFirst();
return roleMapping;
}else{
return nullValue;
}