List of usage examples for java.util Collections EMPTY_MAP
Map EMPTY_MAP
To view the source code for java.util Collections EMPTY_MAP.
Click Source Link
From source file:org.commonreality.object.delta.FullObjectDelta.java
public FullObjectDelta(ISimulationObject object) { super(object.getIdentifier(), Collections.EMPTY_MAP, Collections.EMPTY_MAP); for (String key : object.getProperties()) _newValues.put(key, object.getProperty(key)); }
From source file:net.jcreate.e3.table.model.MapDataModel.java
public MapDataModel(Map pDatas, SortInfo pSortInfo, PageInfo pNavInfo) { super(pSortInfo, pNavInfo); if (pDatas == null) { this.datas = Collections.EMPTY_MAP; } else {// w w w .jav a 2 s .c om this.datas = pDatas; } this.datasIterator = datas.entrySet().iterator(); }
From source file:fr.esiea.esieaddress.service.exception.security.InvalidLoginException.java
public InvalidLoginException() { super(HttpStatus.UNAUTHORIZED.value(), Collections.EMPTY_MAP); }
From source file:fr.esiea.esieaddress.service.exception.security.NeedToBeAuthenticatedException.java
public NeedToBeAuthenticatedException() { super(HttpStatus.UNAUTHORIZED.value(), Collections.EMPTY_MAP); }
From source file:org.codehaus.griffon.runtime.domain.GriffonDomainConfigurationUtil.java
/** * Returns the association map for the specified domain class * * @param domainClass the domain class// w ww .ja v a2 s .c o m * @return The association map */ public static Map<?, ?> getAssociationMap(Class<?> domainClass) { ClassPropertyFetcher cpf = ClassPropertyFetcher.forClass(domainClass); Map<?, ?> associationMap = cpf.getPropertyValue(GriffonDomainProperty.HAS_MANY, Map.class); if (associationMap == null) { associationMap = Collections.EMPTY_MAP; } return associationMap; }
From source file:net.shopxx.BaseAttributeConverter.java
public Object convertToEntityAttribute(String dbData) { if (StringUtils.isEmpty(dbData)) { if (List.class.isAssignableFrom(javaType.getRawClass())) { return Collections.EMPTY_LIST; } else if (Set.class.isAssignableFrom(javaType.getRawClass())) { return Collections.EMPTY_SET; } else if (Map.class.isAssignableFrom(javaType.getRawClass())) { return Collections.EMPTY_MAP; } else {/*from w ww. ja v a 2 s .c om*/ return null; } } return JsonUtils.toObject(dbData, javaType); }
From source file:fr.esiea.esieaddress.service.exception.security.NotConnectedException.java
public NotConnectedException() { super(HttpStatus.NOT_FOUND.value(), Collections.EMPTY_MAP); }
From source file:com.github.nethad.clustermeister.provisioning.jppf.DriverLoadBalancing.java
public Map<String, String> getLoadBalancingConfigValues() { if (configuration == null) { return Collections.EMPTY_MAP; }//from w w w .j a va 2 s. c om LinkedHashMap<String, String> values = new LinkedHashMap<String, String>(); algorithm = configuration.getString(ALGORITHM); strategy = configuration.getString(STRATEGY); strategies = getStrategies(); if (isBrokenConfiguration()) { return Collections.EMPTY_MAP; } values.put(JPPFConstants.LOAD_BALANCING_ALGORITHM, algorithm); values.put(JPPFConstants.LOAD_BALANCING_STRATEGY, "cmprofile"); Map<String, String> strategyValues = strategies.get(strategy); for (Map.Entry<String, String> entry : strategyValues.entrySet()) { values.put("strategy.cmprofile." + entry.getKey(), entry.getValue()); } return values; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.SelectListGenerator.java
public static Map<String, String> getOptions(EditConfiguration editConfig, String fieldName, WebappDaoFactory wDaoFact) {//from w w w . ja v a2s . c o m if (editConfig == null) { log.error("fieldToSelectItemList() must be called with a non-null EditConfiguration "); return Collections.EMPTY_MAP; } if (fieldName == null) { log.error("fieldToSelectItemList() must be called with a non-null fieldName"); return Collections.EMPTY_MAP; } Field field = editConfig.getField(fieldName); if (field == null) { log.error("no field \"" + fieldName + "\" found from editConfig in SelectListGenerator.getOptions()"); return Collections.EMPTY_MAP; } // now create an empty HashMap to populate and return HashMap<String, String> optionsMap = new LinkedHashMap<String, String>(); // for debugging, keep a count of the number of options populated int optionsCount = 0; Field.OptionsType optionsType = field.getOptionsType(); String vclassUri = null; switch (optionsType) { case HARDCODED_LITERALS: // not auto-sorted, and empty values not removed or replaced List<List<String>> hardcodedLiteralOptions = field.getLiteralOptions(); if (hardcodedLiteralOptions == null) { log.error("no literalOptions List found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType HARDCODED_LITERALS specified"); return new HashMap<String, String>(); } for (Object obj : ((Iterable) hardcodedLiteralOptions)) { List<String> literalPair = (List) obj; String value = (String) literalPair.get(0); if (value != null) { // allow empty string as a value String label = (String) literalPair.get(1); if (label != null) { optionsMap.put(value, label); } else { optionsMap.put(value, value); } ++optionsCount; } } break; case LITERALS: List<List<String>> literalOptions = field.getLiteralOptions(); if (literalOptions == null) { log.error("no literalOptions List found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType LITERALS specified"); return new HashMap<String, String>(); } for (Object obj : ((Iterable) literalOptions)) { List<String> literalPair = (List) obj; String value = (String) literalPair.get(0); if (value != null && value.trim().length() > 0) { String label = (String) literalPair.get(1); if (label != null && label.trim().length() > 0) { optionsMap.put(value, label); } else { optionsMap.put(value, value); } ++optionsCount; } } break; case STRINGS_VIA_DATATYPE_PROPERTY: log.debug("processing Field \"" + fieldName + "\" optionType as a datatype property predicateUri in SelectListGenerator.getOptions()"); String dataPropUri = field.getPredicateUri(); if (dataPropUri == null || dataPropUri.equals("")) { log.error("no predicate dataPropUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType STRINGS_VIA_DATATYPE_PROPERTY 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 log.debug("finding all choices for data property \"" + dataPropUri + "\" in SelectListGenerator.getOptions()"); if (wDaoFact == null) log.error( "incoming WebappDaoFactory from request is null in SelectListGenerator.getOptions()."); DataPropertyStatementDao dpsDao = wDaoFact.getDataPropertyStatementDao(); DataPropertyDao dpDao = wDaoFact.getDataPropertyDao(); DataProperty dp = dpDao.getDataPropertyByURI(dataPropUri); for (Iterator<DataPropertyStatement> i = dpsDao.getDataPropertyStatements(dp).iterator(); i .hasNext();) { DataPropertyStatement dps = i.next(); if (dps != null) { optionsMap.put(dps.getData().trim(), dps.getData().trim()); ++optionsCount; } } } break; case INDIVIDUALS_VIA_OBJECT_PROPERTY: log.debug("processing Field \"" + fieldName + "\" optionType as an object property predicateUri in SelectListGenerator.getOptions()"); String subjectUri = editConfig.getSubjectUri(); if (subjectUri == null || subjectUri.equals("")) { log.error("no subjectUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_OBJECTPROPERTY specified"); } else { String predicateUri = field.getPredicateUri(); if (predicateUri == null || predicateUri.equals("")) { log.error("no predicateUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_OBJECTPROPERTY 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 log.debug("finding range individuals for subject \"" + subjectUri + "\" and object property \"" + predicateUri + "\" in SelectListGenerator.getOptions()"); if (wDaoFact == null) log.error( "could not get WebappDaoFactory from request in SelectListGenerator.getOptions()."); Individual subject = wDaoFact.getIndividualDao().getIndividualByURI(subjectUri); if (subject == null) log.error("could not get individual for subject uri " + subjectUri + " in SelectListGenerator.getOptions()"); ObjectProperty objProp = wDaoFact.getObjectPropertyDao().getObjectPropertyByURI(predicateUri); if (objProp == null) log.error("could not get object property for predicate " + predicateUri + " in SelectListGenerator.getOptions()"); List<VClass> vclasses = new ArrayList<VClass>(); vclasses = wDaoFact.getVClassDao().getVClassesForProperty(subject.getVClassURI(), predicateUri); if (vclasses == null) { log.error("no owl:Class found for predicate " + predicateUri); break; } if (vclasses.size() == 0) log.error("no owl:Class found for predicate " + predicateUri); List<Individual> individuals = new ArrayList<Individual>(); HashSet<String> uriSet = new HashSet<String>(); long startTime = System.currentTimeMillis(); for (VClass vclass : vclasses) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (!uriSet.contains(ind.getURI())) { uriSet.add(ind.getURI()); individuals.add(ind); } } } List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements(); if (stmts == null) log.error("object properties for subject were null in SelectListGenerator.getOptions()"); individuals = removeIndividualsAlreadyInRange(individuals, stmts, predicateUri, editConfig.getObject()); //Collections.sort(individuals,new compareIndividualsByName()); for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { optionsMap.put(uri, ind.getName().trim()); ++optionsCount; } } } } break; case INDIVIDUALS_VIA_VCLASS: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_VCLASS 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()."); // if reasoning isn't available, we will also need to add // individuals asserted in subclasses boolean inferenceAvailable = false; if (wDaoFact instanceof WebappDaoFactoryJena) { PelletListener pl = ((WebappDaoFactoryJena) wDaoFact).getPelletListener(); if (pl != null && pl.isConsistent() && !pl.isInErrorState() && !pl.isReasoning()) { inferenceAvailable = true; } } VClass vclass = wDaoFact.getVClassDao().getVClassByURI(vclassUri); if (vclass == null) { log.error("Cannot find owl:Class " + vclassUri + " in the model"); optionsMap.put("", "Could not find class " + vclassUri); } else { Map<String, Individual> individualMap = new HashMap<String, Individual>(); for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } if (!inferenceAvailable) { for (String subclassURI : wDaoFact.getVClassDao().getAllSubClassURIs(vclass.getURI())) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(subclassURI, -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } } } List<Individual> individuals = new ArrayList<Individual>(); individuals.addAll(individualMap.values()); Collections.sort(individuals); for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } if (!inferenceAvailable) { for (String subclassURI : wDaoFact.getVClassDao().getAllSubClassURIs(vclass.getURI())) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(subclassURI, -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } } } individuals.addAll(individualMap.values()); Collections.sort(individuals); if (individuals.size() == 0) { log.error("No individuals of type " + vclass.getName() + " to add to pick list in SelectListGenerator.getOptions()"); optionsMap.put("", "No " + vclass.getName() + " found"); } else { for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { optionsMap.put(uri, ind.getName().trim()); ++optionsCount; } } } } } break; case CHILD_VCLASSES: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType CHILD_VCLASSES 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()."); VClassDao vclassDao = wDaoFact.getVClassDao(); List<String> subClassList = vclassDao.getAllSubClassURIs(vclassUri); if (subClassList == null || subClassList.size() == 0) { log.debug("No subclasses of " + vclassUri + " found in the model so only default value from field's literalOptions will be used"); } else { for (String subClassUri : subClassList) { VClass subClass = vclassDao.getVClassByURI(subClassUri); if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) { optionsMap.put(subClassUri, subClass.getName().trim()); ++optionsCount; } } } } break; case CHILD_VCLASSES_WITH_PARENT: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType CHILD_VCLASSES 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()."); VClassDao vclassDao = wDaoFact.getVClassDao(); List<String> subClassList = vclassDao.getAllSubClassURIs(vclassUri); if (subClassList == null || subClassList.size() == 0) { log.debug("No subclasses of " + vclassUri + " found in the model so only default value from field's literalOptions will be used"); } else { for (String subClassUri : subClassList) { VClass subClass = vclassDao.getVClassByURI(subClassUri); if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) { optionsMap.put(subClassUri, subClass.getName().trim()); ++optionsCount; } } optionsMap.put(vclassUri, "Other"); ++optionsCount; } } 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; default: log.error("unknown optionsType " + optionsType.toString() + " for Field \"" + fieldName + "\" in SelectListGenerator.getOptions()"); } log.debug("added " + optionsCount + " options for field \"" + fieldName + "\" in SelectListGenerator.getOptions()"); return optionsMap; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.SelectListGeneratorVTwo.java
public static Map<String, String> getOptions(EditConfigurationVTwo editConfig, String fieldName, WebappDaoFactory wDaoFact) {//w w w . ja v a2 s . co m if (editConfig == null) { log.error("fieldToSelectItemList() must be called with a non-null EditConfigurationVTwo "); return Collections.EMPTY_MAP; } if (fieldName == null) { log.error("fieldToSelectItemList() must be called with a non-null fieldName"); return Collections.EMPTY_MAP; } FieldVTwo field = editConfig.getField(fieldName); if (field == null) { log.error("no field \"" + fieldName + "\" found from editConfig in SelectListGenerator.getOptions()"); return Collections.EMPTY_MAP; } // now create an empty HashMap to populate and return HashMap<String, String> optionsMap = new LinkedHashMap<String, String>(); // for debugging, keep a count of the number of options populated int optionsCount = 0; FieldVTwo.OptionsType optionsType = field.getOptionsType(); String vclassUri = null; switch (optionsType) { case HARDCODED_LITERALS: // not auto-sorted, and empty values not removed or replaced List<List<String>> hardcodedLiteralOptions = field.getLiteralOptions(); if (hardcodedLiteralOptions == null) { log.error("no literalOptions List found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType HARDCODED_LITERALS specified"); return new HashMap<String, String>(); } for (Object obj : ((Iterable) hardcodedLiteralOptions)) { List<String> literalPair = (List) obj; String value = (String) literalPair.get(0); if (value != null) { // allow empty string as a value String label = (String) literalPair.get(1); if (label != null) { optionsMap.put(value, label); } else { optionsMap.put(value, value); } ++optionsCount; } } break; case LITERALS: List<List<String>> literalOptions = field.getLiteralOptions(); if (literalOptions == null) { log.error("no literalOptions List found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType LITERALS specified"); return new HashMap<String, String>(); } for (Object obj : ((Iterable) literalOptions)) { List<String> literalPair = (List) obj; String value = (String) literalPair.get(0); if (value != null && value.trim().length() > 0) { String label = (String) literalPair.get(1); if (label != null && label.trim().length() > 0) { optionsMap.put(value, label); } else { optionsMap.put(value, value); } ++optionsCount; } } break; case STRINGS_VIA_DATATYPE_PROPERTY: log.debug("processing Field \"" + fieldName + "\" optionType as a datatype property predicateUri in SelectListGenerator.getOptions()"); String dataPropUri = field.getPredicateUri(); if (dataPropUri == null || dataPropUri.equals("")) { log.error("no predicate dataPropUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType STRINGS_VIA_DATATYPE_PROPERTY 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 log.debug("finding all choices for data property \"" + dataPropUri + "\" in SelectListGenerator.getOptions()"); if (wDaoFact == null) log.error( "incoming WebappDaoFactory from request is null in SelectListGenerator.getOptions()."); DataPropertyStatementDao dpsDao = wDaoFact.getDataPropertyStatementDao(); DataPropertyDao dpDao = wDaoFact.getDataPropertyDao(); DataProperty dp = dpDao.getDataPropertyByURI(dataPropUri); for (Iterator<DataPropertyStatement> i = dpsDao.getDataPropertyStatements(dp).iterator(); i .hasNext();) { DataPropertyStatement dps = i.next(); if (dps != null) { optionsMap.put(dps.getData().trim(), dps.getData().trim()); ++optionsCount; } } } break; case INDIVIDUALS_VIA_OBJECT_PROPERTY: log.debug("processing Field \"" + fieldName + "\" optionType as an object property predicateUri in SelectListGenerator.getOptions()"); String subjectUri = editConfig.getSubjectUri(); if (subjectUri == null || subjectUri.equals("")) { log.error("no subjectUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_OBJECTPROPERTY specified"); } else { String predicateUri = field.getPredicateUri(); if (predicateUri == null || predicateUri.equals("")) { log.error("no predicateUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_OBJECTPROPERTY 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 log.debug("finding range individuals for subject \"" + subjectUri + "\" and object property \"" + predicateUri + "\" in SelectListGenerator.getOptions()"); if (wDaoFact == null) log.error( "could not get WebappDaoFactory from request in SelectListGenerator.getOptions()."); Individual subject = wDaoFact.getIndividualDao().getIndividualByURI(subjectUri); if (subject == null) log.error("could not get individual for subject uri " + subjectUri + " in SelectListGenerator.getOptions()"); ObjectProperty objProp = wDaoFact.getObjectPropertyDao().getObjectPropertyByURI(predicateUri); if (objProp == null) log.error("could not get object property for predicate " + predicateUri + " in SelectListGenerator.getOptions()"); List<VClass> vclasses = new ArrayList<VClass>(); vclasses = wDaoFact.getVClassDao().getVClassesForProperty(subject.getVClassURI(), predicateUri); if (vclasses == null) { log.error("no owl:Class found for predicate " + predicateUri); break; } if (vclasses.size() == 0) log.error("no owl:Class found for predicate " + predicateUri); List<Individual> individuals = new ArrayList<Individual>(); HashSet<String> uriSet = new HashSet<String>(); long startTime = System.currentTimeMillis(); for (VClass vclass : vclasses) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (!uriSet.contains(ind.getURI())) { uriSet.add(ind.getURI()); individuals.add(ind); } } } List<ObjectPropertyStatement> stmts = subject.getObjectPropertyStatements(); if (stmts == null) log.error("object properties for subject were null in SelectListGenerator.getOptions()"); individuals = removeIndividualsAlreadyInRange(individuals, stmts, predicateUri, editConfig.getObject()); //Collections.sort(individuals,new compareIndividualsByName()); for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { optionsMap.put(uri, ind.getName().trim()); ++optionsCount; } } } } break; case INDIVIDUALS_VIA_VCLASS: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType INDIVIDUALS_VIA_VCLASS 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()."); // if reasoning isn't available, we will also need to add // individuals asserted in subclasses boolean inferenceAvailable = false; if (wDaoFact instanceof WebappDaoFactoryJena) { PelletListener pl = ((WebappDaoFactoryJena) wDaoFact).getPelletListener(); if (pl != null && pl.isConsistent() && !pl.isInErrorState() && !pl.isReasoning()) { inferenceAvailable = true; } } VClass vclass = wDaoFact.getVClassDao().getVClassByURI(vclassUri); if (vclass == null) { log.error("Cannot find owl:Class " + vclassUri + " in the model"); optionsMap.put("", "Could not find class " + vclassUri); } else { Map<String, Individual> individualMap = new HashMap<String, Individual>(); for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } if (!inferenceAvailable) { for (String subclassURI : wDaoFact.getVClassDao().getAllSubClassURIs(vclass.getURI())) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(subclassURI, -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } } } List<Individual> individuals = new ArrayList<Individual>(); individuals.addAll(individualMap.values()); Collections.sort(individuals); for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } if (!inferenceAvailable) { for (String subclassURI : wDaoFact.getVClassDao().getAllSubClassURIs(vclass.getURI())) { for (Individual ind : wDaoFact.getIndividualDao().getIndividualsByVClassURI(subclassURI, -1, -1)) { if (ind.getURI() != null) { individualMap.put(ind.getURI(), ind); } } } } individuals.addAll(individualMap.values()); Collections.sort(individuals); if (individuals.size() == 0) { log.error("No individuals of type " + vclass.getName() + " to add to pick list in SelectListGenerator.getOptions()"); optionsMap.put("", "No " + vclass.getName() + " found"); } else { for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { optionsMap.put(uri, ind.getName().trim()); ++optionsCount; } } } } } break; case CHILD_VCLASSES: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType CHILD_VCLASSES 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()."); VClassDao vclassDao = wDaoFact.getVClassDao(); List<String> subClassList = vclassDao.getAllSubClassURIs(vclassUri); if (subClassList == null || subClassList.size() == 0) { log.debug("No subclasses of " + vclassUri + " found in the model so only default value from field's literalOptions will be used"); } else { for (String subClassUri : subClassList) { VClass subClass = vclassDao.getVClassByURI(subClassUri); if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) { optionsMap.put(subClassUri, subClass.getName().trim()); ++optionsCount; } } } } break; case CHILD_VCLASSES_WITH_PARENT: //so we have a vclass URI vclassUri = field.getObjectClassUri(); if (vclassUri == null || vclassUri.equals("")) { log.error("no vclassUri found for field \"" + fieldName + "\" in SelectListGenerator.getOptions() when OptionsType CHILD_VCLASSES 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()."); VClassDao vclassDao = wDaoFact.getVClassDao(); List<String> subClassList = vclassDao.getAllSubClassURIs(vclassUri); if (subClassList == null || subClassList.size() == 0) { log.debug("No subclasses of " + vclassUri + " found in the model so only default value from field's literalOptions will be used"); } else { for (String subClassUri : subClassList) { VClass subClass = vclassDao.getVClassByURI(subClassUri); if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) { optionsMap.put(subClassUri, subClass.getName().trim()); ++optionsCount; } } optionsMap.put(vclassUri, "Other"); ++optionsCount; } } 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; default: log.error("unknown optionsType " + optionsType.toString() + " for Field \"" + fieldName + "\" in SelectListGenerator.getOptions()"); } log.debug("added " + optionsCount + " options for field \"" + fieldName + "\" in SelectListGenerator.getOptions()"); return optionsMap; }