Adds a new complex value which corresponds to a choice element.<p>

@param reference the reference view
@param choicePath the path of choice attribute names
501738
private void addComplexChoiceValue(CmsAttributeValueView reference, List<String> choicePath) {

        CmsEntity value = m_entityBackEnd.createEntity(null, getAttributeType().getId());
        CmsEntity parentValue = value;
        for (String attributeChoice : choicePath) {
            CmsType choiceType = m_entityBackEnd.getType(parentValue.getTypeName()).getAttributeType(
                CmsType.CHOICE_ATTRIBUTE_NAME);
            CmsEntity choice = m_entityBackEnd.createEntity(null, choiceType.getId());
            parentValue.addAttributeValue(CmsType.CHOICE_ATTRIBUTE_NAME, choice);
            CmsType choiceOptionType = choiceType.getAttributeType(attributeChoice);
            if (choiceOptionType.isSimpleType()) {
                String choiceValue = m_widgetService.getDefaultAttributeValue(attributeChoice, getSimplePath(0));
                choice.addAttributeValue(attributeChoice, choiceValue);
                break;
            } else {
                CmsEntity choiceValue = m_entityBackEnd.createEntity(null, choiceOptionType.getId());
                choice.addAttributeValue(attributeChoice, choiceValue);
                parentValue = choiceValue;
            }
        }
        insertValueAfterReference(value, reference);
        if (getMaxOccurence() == 1) {
            reference.setCollapsed(true);
        }
    }
461579
def _create_reference_value_options(self, keys, finished_keys):
        """"""
        # a set of known reference_value_from_links
        set_of_reference_value_option_names = set()
        for key in keys:
            if key in finished_keys:
                continue
            an_option = self.option_definitions[key]
            if an_option.reference_value_from:

                fully_qualified_reference_name = '.'.join((
                    an_option.reference_value_from,
                    an_option.name
                ))
                if fully_qualified_reference_name in keys:
                    continue  # this referenced value has already been defined
                              # no need to repeat it - skip on to the next key
                reference_option = an_option.copy()
                reference_option.reference_value_from = None
                reference_option.name = fully_qualified_reference_name
                # wait, aren't we setting a fully qualified dotted name into
                # the name field?  Yes, 'add_option' below sees that
                # full pathname and does the right thing with it to ensure
                # that the reference_option is created within the
                # correct namespace
                set_of_reference_value_option_names.add(
                    fully_qualified_reference_name
                )
                self.option_definitions.add_option(reference_option)

        for a_reference_value_option_name in set_of_reference_value_option_names:
            for x in range(a_reference_value_option_name.count('.')):
                namespace_path = \
                    a_reference_value_option_name.rsplit('.', x + 1)[0]
                self.option_definitions[namespace_path].ref_value_namespace()

        return set_of_reference_value_option_names
517306
public void addReference(final String propertyName, final Collection<BeanId> refs) {
        Preconditions.checkNotNull(refs);
        Preconditions.checkNotNull(propertyName);
        checkCircularReference(refs.toArray(new BeanId[refs.size()]));
        List<BeanId> list = references.get(propertyName);
        if (list == null) {
            list = new ArrayList<>();
            list.addAll(refs);
            references.put(propertyName, list);
        } else {
            list.addAll(refs);
        }
    }
694345
public void setReference(final Reference reference) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.entry(this, TRACE, "setReference", reference);
        }

        // Make sure no-one can pull the rug from beneath us.
        synchronized (_properties) {
            _properties = JmsJcaReferenceUtils.getInstance()
                            .getMapFromReference(reference, defaultJNDIProperties);
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, "setReference");
        }

    }
734310
private void addPredicateReference(String theResourceName, String theParamName, List<? extends IQueryParameterType> theList) {
		assert theParamName.contains(".") == false;

		if (theList.get(0).getMissing() != null) {
			addPredicateParamMissing(theResourceName, theParamName, theList.get(0).getMissing());
			return;
		}

		Join<ResourceTable, ResourceLink> join = createJoin(JoinEnum.REFERENCE, theParamName);

		List<IIdType> targetIds = new ArrayList<>();
		List<String> targetQualifiedUrls = new ArrayList<>();

		for (int orIdx = 0; orIdx < theList.size(); orIdx++) {
			IQueryParameterType nextOr = theList.get(orIdx);

			if (nextOr instanceof ReferenceParam) {
				ReferenceParam ref = (ReferenceParam) nextOr;

				if (isBlank(ref.getChain())) {

					/*
					 * Handle non-chained search, e.g. Patient?organization=Organization/123
					 */

					IIdType dt = new IdDt(ref.getBaseUrl(), ref.getResourceType(), ref.getIdPart(), null);

					if (dt.hasBaseUrl()) {
						if (myDaoConfig.getTreatBaseUrlsAsLocal().contains(dt.getBaseUrl())) {
							dt = dt.toUnqualified();
							targetIds.add(dt);
						} else {
							targetQualifiedUrls.add(dt.getValue());
						}
					} else {
						targetIds.add(dt);
					}

				} else {

					/*
					 * Handle chained search, e.g. Patient?organization.name=Kwik-e-mart
					 */

					addPredicateReferenceWithChain(theResourceName, theParamName, theList, join, new ArrayList<>(), ref);
					return;

				}

			} else {
				throw new IllegalArgumentException("Invalid token type (expecting ReferenceParam): " + nextOr.getClass());
			}

		}

		List<Predicate> codePredicates = new ArrayList<>();

		// Resources by ID
		List<Long> targetPids = myIdHelperService.translateForcedIdToPids(targetIds);
		if (!targetPids.isEmpty()) {
			ourLog.debug("Searching for resource link with target PIDs: {}", targetPids);
			Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
			Predicate pidPredicate = join.get("myTargetResourcePid").in(targetPids);
			codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
		}

		// Resources by fully qualified URL
		if (!targetQualifiedUrls.isEmpty()) {
			ourLog.debug("Searching for resource link with target URLs: {}", targetQualifiedUrls);
			Predicate pathPredicate = createResourceLinkPathPredicate(theResourceName, theParamName, join);
			Predicate pidPredicate = join.get("myTargetResourceUrl").in(targetQualifiedUrls);
			codePredicates.add(myBuilder.and(pathPredicate, pidPredicate));
		}

		if (codePredicates.size() > 0) {
			myPredicates.add(myBuilder.or(toArray(codePredicates)));
		} else {
			// Add a predicate that will never match
			Predicate pidPredicate = join.get("myTargetResourcePid").in(-1L);
			myPredicates.clear();
			myPredicates.add(pidPredicate);
		}
	}
990379
public void addNewAttributeValueToEntity(int referenceIndex) {

        // make sure not to add more values than allowed
        int maxOccurrence = getEntityType().getAttributeMaxOccurrence(m_attributeName);
        CmsEntityAttribute attribute = m_entity.getAttribute(m_attributeName);
        boolean mayHaveMore = ((attribute == null) || (attribute.getValueCount() < maxOccurrence));
        if (mayHaveMore) {
            if (getAttributeType().isSimpleType()) {
                String defaultValue = m_widgetService.getDefaultAttributeValue(
                    m_attributeName,
                    getSimplePath(referenceIndex + 1));
                if ((attribute == null) || (attribute.getValueCount() == (referenceIndex + 1))) {
                    m_entity.addAttributeValue(m_attributeName, defaultValue);
                } else {
                    m_entity.insertAttributeValue(m_attributeName, defaultValue, referenceIndex + 1);
                    m_widgetService.addChangedOrderPath(getSimplePath(-1));
                }
            } else {
                CmsEntity value = m_entityBackEnd.createEntity(null, m_attributeType.getId());
                if ((attribute == null) || (attribute.getValueCount() == (referenceIndex + 1))) {
                    m_entity.addAttributeValue(m_attributeName, value);
                } else {
                    m_entity.insertAttributeValue(m_attributeName, value, referenceIndex + 1);
                    m_widgetService.addChangedOrderPath(getSimplePath(-1));
                }
                insertHandlers(referenceIndex + 1);
            }
        }
    }
804244
public void addOption(OPTION cell) {

        String value = cell.getValue();
        boolean first = m_selectCells.isEmpty();
        m_selectCells.put(value, cell);

        m_selector.add(cell);
        if (first) {
            selectValue(value);
            m_firstValue = value;
        }
        initSelectCell(cell);
    }
323181
public static <T> Option<T> some(T reference) {
    return new Some<T>(Assert.notNull(reference));
  }
328498
public void addOption(String value, String text) {

        String title = getTitle(value, text);
        CmsLabelSelectCell cell = new CmsLabelSelectCell(value, text, title);
        addOption(cell);
    }
727642
public XMLAttributeList addOptionalAttribute(@Nonnull String name, @CheckForNull String value) {
        if (value == null) {
            return this;
        }
        return addAttribute(name, value);
    }
1020857
static public function choice($value, array $choices, $message = null, $propertyPath = null)
        {
            if (!Arrays::in($value, $choices, true)) {
                $message = $message ?: sprintf(
                    'Value "%s" is not an element of the valid values: %s',
                    static::stringify($value),
                    implode(", ", array_map('Assert\Assertion::stringify', $choices))
                );

                throw static::createException($value, $message, static::INVALID_CHOICE, $propertyPath, array('choices' => $choices));
            }
        }
1326972
public void addAttributeValue(String attributeName, CmsEntity value) {

        if (m_simpleAttributes.containsKey(attributeName)) {
            throw new RuntimeException("Attribute already exists with a simple type value.");
        }
        if (m_entityAttributes.containsKey(attributeName)) {
            m_entityAttributes.get(attributeName).add(value);
        } else {
            List<CmsEntity> values = new ArrayList<CmsEntity>();
            values.add(value);
            m_entityAttributes.put(attributeName, values);
        }
        registerChangeHandler(value);
        fireChange();
    }
18061
protected void addOption(AbstractRenderAppender buffer, String type, String optionValue,
                             String optionDisplay, int idx, String altText, char accessKey, boolean disabled)
            throws JspException
    {
        ServletRequest req = pageContext.getRequest();
        if (_cr == null)
            _cr = TagRenderingBase.Factory.getConstantRendering(req);

        assert(buffer != null);
        assert(optionValue != null);
        assert(optionDisplay != null);
        assert(type != null);

        if (_orientation != null && isVertical()) {
            _cr.TR_TD(buffer);
        }

        _inputState.clear();
        _inputState.type = type;
        _inputState.name = getQualifiedDataSourceName();
        _inputState.value = optionValue;
        _inputState.style = _style;
        _inputState.styleClass = _class;

        if (isMatched(optionValue, null)) {
            _inputState.checked = true;
        }
        _inputState.disabled = isDisabled();
        _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ALT, altText);
        if (accessKey != 0x00)
            _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, ACCESSKEY, Character.toString(accessKey));

        // if there are attributes defined push them to the options.
        if (_attrs != null && _attrs.size() > 0) {
            Iterator iterator = _attrs.keySet().iterator();
            for (; iterator.hasNext();) {
                String key = (String) iterator.next();
                if (key == null)
                    continue;

                String value = (String) _attrs.get(key);
                _inputState.registerAttribute(AbstractHtmlState.ATTR_GENERAL, key, value);
            }
        }

        TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_BOOLEAN_TAG, req);
        br.doStartTag(buffer, _inputState);
        br.doEndTag(buffer);

        String ls = _labelStyle;
        String lsc = _labelStyleClass;

        _spanState.style = ls;
        _spanState.styleClass = lsc;

        br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SPAN_TAG, req);
        br.doStartTag(buffer, _spanState);
        buffer.append(optionDisplay);
        br.doEndTag(buffer);

        // backward compatibility this is now overridden by the _orientation
        if (_orientation == null) {
            _cr.BR(buffer);
        }
        else {
            if (isVertical()) {
                _cr.TR_TD(buffer);
            }
            else {
                _cr.NBSP(buffer);
            }
        }
    }
1142372
private void addOption(Type type, String siteRoot, String message) {

        if (m_usedSiteRoots.contains(CmsStringUtil.joinPaths(siteRoot, "/"))) {
            return;
        }
        CmsSiteSelectorOption option = new CmsSiteSelectorOption(type, siteRoot, m_siteRoot.equals(siteRoot), message);

        // make sure to insert the root site is first and the shared site as second entry
        if (Type.root.equals(type)) {
            m_options.add(0, option);
        } else if (Type.shared.equals(type)) {
            if (!m_options.isEmpty() && Type.root.equals(m_options.get(0).getType())) {
                m_options.add(1, option);
            } else {
                m_options.add(0, option);
            }
        } else {
            m_options.add(option);
        }
        m_usedSiteRoots.add(CmsStringUtil.joinPaths(siteRoot, "/"));
    }
849618
public static <T> DropDownChoice<T> newDropDownChoice(final String id, final IModel<T> model,
		final List<? extends T> choices)
	{
		final DropDownChoice<T> dropDownChoice = new DropDownChoice<>(id, model, choices);
		dropDownChoice.setOutputMarkupId(true);
		return dropDownChoice;
	}
65058
@Indexable(type = IndexableType.REINDEX)
	@Override
	public CPDefinitionOptionRel addCPDefinitionOptionRel(
		CPDefinitionOptionRel cpDefinitionOptionRel) {
		cpDefinitionOptionRel.setNew(true);

		return cpDefinitionOptionRelPersistence.update(cpDefinitionOptionRel);
	}
1178924
public Option choices(String... choices) throws RequiredParametersException {
		if (this.defaultValue != null) {
			if (Arrays.asList(choices).contains(defaultValue)) {
				Collections.addAll(this.choices, choices);
			} else {
				throw new RequiredParametersException("Valid values for option " + this.longName +
						" do not contain defined default value " + defaultValue);
			}
		} else {
			Collections.addAll(this.choices, choices);
		}
		return this;
	}