NIHVIVO-725 Add VClassGroup type to SelectListGenerator in order to generate a select list of all classes belonging to publication classgroup for publication custom form.
This commit is contained in:
parent
f208d72d10
commit
e972fd5549
3 changed files with 64 additions and 21 deletions
|
@ -24,6 +24,7 @@ public class Field {
|
|||
MONIKERS_VIA_VCLASS,
|
||||
CHILD_VCLASSES,
|
||||
CHILD_VCLASSES_WITH_PARENT,
|
||||
VCLASSGROUP,
|
||||
FILE,
|
||||
UNDEFINED,
|
||||
DATETIME,
|
||||
|
@ -217,6 +218,8 @@ public class Field {
|
|||
setOptionsType(Field.OptionsType.CHILD_VCLASSES);
|
||||
} else if ("CHILD_VCLASSES_WITH_PARENT".equalsIgnoreCase(s)) {
|
||||
setOptionsType(Field.OptionsType.CHILD_VCLASSES_WITH_PARENT);
|
||||
} else if ("VCLASSGROUP".equalsIgnoreCase(s)) {
|
||||
setOptionsType(Field.OptionsType.VCLASSGROUP);
|
||||
} else if ("FILE".equalsIgnoreCase(s)) {
|
||||
setOptionsType(Field.OptionsType.FILE);
|
||||
} else if ("DATE".equalsIgnoreCase(s)) {
|
||||
|
|
|
@ -22,9 +22,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
|
||||
public class SelectListGenerator {
|
||||
|
@ -235,6 +237,7 @@ public class SelectListGenerator {
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CHILD_VCLASSES: //so we have a vclass URI
|
||||
vclassUri = field.getObjectClassUri();
|
||||
if (vclassUri==null || vclassUri.equals("")){
|
||||
|
@ -295,6 +298,57 @@ public class SelectListGenerator {
|
|||
}
|
||||
break;
|
||||
|
||||
case VCLASSGROUP:
|
||||
|
||||
String classGroupUri = field.getObjectClassUri(); // we're overloading this property to specify the classgroup
|
||||
if (classGroupUri==null || classGroupUri.equals("")){
|
||||
log.error("no classGroupUri found for field \""+fieldName+"\" in SelectListGenerator.getOptions() when OptionsType VCLASSGROUP specified");
|
||||
} else {
|
||||
// first test to see whether there's a default "leave blank" value specified with the literal options
|
||||
String defaultOption=null;
|
||||
if ((defaultOption=getDefaultOption(field))!=null) {
|
||||
optionsMap.put(LEFT_BLANK, defaultOption);
|
||||
}
|
||||
// now populate the options
|
||||
if( wDaoFact == null ) log.error("could not get WebappDaoFactory from request in SelectListGenerator.getOptions().");
|
||||
|
||||
VClassGroupDao vcgd = wDaoFact.getVClassGroupDao();
|
||||
|
||||
// Need to call this method to populate the classgroups - otherwise the classgroup class list is empty
|
||||
List vClassGroups = vcgd.getPublicGroupsWithVClasses();
|
||||
|
||||
if (vClassGroups == null) {
|
||||
log.error("No class groups found, so only default value from field's literalOptions will be used.");
|
||||
} else {
|
||||
VClassGroup vClassGroup = null;
|
||||
for (Object o : vClassGroups) {
|
||||
VClassGroup vcg = (VClassGroup) o;
|
||||
if (vcg.getURI().equals(classGroupUri)) {
|
||||
vClassGroup = vcg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (vClassGroup == null) {
|
||||
log.error("No class group with uri " + classGroupUri + "found, so only default value from field's literalOptions will be used.");
|
||||
} else {
|
||||
List<VClass> vClassList = vClassGroup.getVitroClassList();
|
||||
|
||||
if( vClassList == null || vClassList.size()==0 ) {
|
||||
log.debug("No classes in class group " + classGroupUri + " found in the model, so only default value from field's literalOptions will be used" );
|
||||
} else {
|
||||
for( VClass vClass : vClassList ) {
|
||||
String vClassUri = vClass.getURI();
|
||||
if( vClass != null && !OWL.Nothing.getURI().equals(vClassUri)) {
|
||||
optionsMap.put(vClassUri,vClass.getName().trim());
|
||||
++optionsCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case UNDEFINED :
|
||||
log.error("optionsType \"UNDEFINED\" for Field \""+fieldName+"\" in SelectListGenerator.getOptions()");
|
||||
break;
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
function validate_upload_file(form_passed) {
|
||||
|
||||
var msg="";
|
||||
|
||||
if (form_passed.datafile.value == "") msg += "Please browse and select a photo\n";
|
||||
|
||||
|
||||
if (msg == "") {
|
||||
|
||||
document.form_upload_image.submit();
|
||||
|
||||
|
||||
} else{
|
||||
|
||||
alert(msg);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function validate_upload_file(form_passed){
|
||||
|
||||
if (form_passed.datafile.value == "") {
|
||||
alert ("Please browse and select a photo");
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue