use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class RelationRegistryImpl method createRelationDefinitionFromStaticDefinition.
@NotNull
static RelationDefinitionType createRelationDefinitionFromStaticDefinition(RelationTypes defaultRelationDefinition) {
RelationDefinitionType relationDef = new RelationDefinitionType();
relationDef.setRef(defaultRelationDefinition.getRelation());
DisplayType display = new DisplayType();
PolyStringType label = new PolyStringType(QNameUtil.getLocalPart(defaultRelationDefinition.getRelation()));
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey(defaultRelationDefinition.getLabelKey());
label.setTranslation(translation);
display.setLabel(label);
if (StringUtils.isNotEmpty(defaultRelationDefinition.getDefaultIconStyle())) {
IconType icon = new IconType();
icon.setCssClass(defaultRelationDefinition.getDefaultIconStyle());
if (StringUtils.isNotEmpty(defaultRelationDefinition.getDefaultIconColor())) {
icon.setColor(defaultRelationDefinition.getDefaultIconColor());
}
display.setIcon(icon);
}
relationDef.setDisplay(display);
relationDef.setDefaultFor(defaultRelationDefinition.getDefaultFor());
relationDef.getKind().addAll(defaultRelationDefinition.getKinds());
relationDef.getCategory().addAll(Arrays.asList(defaultRelationDefinition.getCategories()));
relationDef.setStaticallyDefined(true);
return relationDef;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class TaskHandlerWrapperFactory method getPredefinedValues.
@Override
protected LookupTableType getPredefinedValues(PrismProperty<String> item, WrapperContext ctx) {
PrismObject<?> prismObject = getParent(ctx);
if (prismObject == null || !TaskType.class.equals(prismObject.getCompileTimeClass())) {
return super.getPredefinedValues(item, ctx);
}
LookupTableType parentLookup = super.getPredefinedValues(item, ctx);
if (parentLookup != null) {
return parentLookup;
}
TaskType task = (TaskType) prismObject.asObjectable();
Collection<AssignmentType> assignmentTypes = task.getAssignment().stream().filter(WebComponentUtil::isArchetypeAssignment).collect(Collectors.toList());
Collection<String> handlers;
if (assignmentTypes.isEmpty()) {
handlers = getTaskManager().getAllHandlerUris(true);
} else if (assignmentTypes.size() == 1) {
AssignmentType archetypeAssignment = assignmentTypes.iterator().next();
handlers = getTaskManager().getHandlerUrisForArchetype(archetypeAssignment.getTargetRef().getOid(), true);
} else {
try {
PrismObject<ArchetypeType> archetype = archetypeManager.determineStructuralArchetype(task.asPrismObject(), ctx.getResult());
handlers = getTaskManager().getHandlerUrisForArchetype(archetype.getOid(), true);
} catch (SchemaException e) {
throw new UnsupportedOperationException("More than 1 structural archetype, this is not supported", e);
}
}
LookupTableType lookupTableType = new LookupTableType(getPrismContext());
handlers.forEach(handler -> {
LookupTableRowType row = new LookupTableRowType(getPrismContext());
row.setKey(handler);
handler = normalizeHandler(handler);
PolyStringType handlerLabel = new PolyStringType(handler);
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey(handler);
handlerLabel.setTranslation(translation);
row.setLabel(handlerLabel);
lookupTableType.getRow().add(row);
});
return lookupTableType;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class LoggingPackageWrapperFactoryImpl method getPredefinedValues.
public LookupTableType getPredefinedValues(PrismProperty<T> item, WrapperContext wrapperContext) {
LookupTableType lookupTable = new LookupTableType();
List<LookupTableRowType> list = lookupTable.createRowList();
List<StandardLoggerType> standardLoggers = EnumUtils.getEnumList(StandardLoggerType.class);
for (StandardLoggerType standardLogger : standardLoggers) {
LookupTableRowType row = new LookupTableRowType();
row.setKey(standardLogger.getValue());
row.setValue(standardLogger.getValue());
PolyStringType label = new PolyStringType("StandardLoggerType." + standardLogger.name());
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("StandardLoggerType." + standardLogger.name());
label.setTranslation(translation);
row.setLabel(label);
list.add(row);
}
List<LoggingComponentType> componentLoggers = EnumUtils.getEnumList(LoggingComponentType.class);
for (LoggingComponentType componentLogger : componentLoggers) {
LookupTableRowType row = new LookupTableRowType();
String value = ComponentLoggerType.getPackageByValue(componentLogger);
row.setKey(value);
row.setValue(value);
PolyStringType label = new PolyStringType("LoggingComponentType." + componentLogger.name());
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("LoggingComponentType." + componentLogger.name());
label.setTranslation(translation);
row.setLabel(label);
list.add(row);
}
return lookupTable;
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class PolyStringEditorPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
String localizedValue = getLocalizedPolyStringValue();
WebMarkupContainer localizedValueContainer = new WebMarkupContainer(ID_LOCALIZED_VALUE_CONTAINER);
localizedValueContainer.setOutputMarkupId(true);
localizedValueContainer.add(getInputFieldClassAppenderForContainer());
localizedValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isNotEmpty(localizedValue)));
add(localizedValueContainer);
Label localizedValueLabel = new Label(ID_LOCALIZED_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.localizedValue"));
localizedValueLabel.setOutputMarkupId(true);
localizedValueLabel.add(new VisibleBehaviour(() -> showFullData));
localizedValueContainer.add(localizedValueLabel);
WebMarkupContainer localizedValueWithButton = new WebMarkupContainer(ID_LOCALIZED_VALUE_WITH_BUTTON);
localizedValueWithButton.setOutputMarkupId(true);
localizedValueWithButton.add(getInputFieldClassAppender());
localizedValueContainer.add(localizedValueWithButton);
TextPanel<String> localizedValuePanel = new TextPanel<>(ID_LOCALIZED_VALUE_PANEL, Model.of(localizedValue));
localizedValuePanel.setOutputMarkupId(true);
localizedValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
localizedValuePanel.add(new EnableBehaviour(() -> false));
localizedValueWithButton.add(localizedValuePanel);
AjaxButton showHideLanguagesLocalizedButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_LOCALIZED) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesLocalizedButton.setOutputMarkupId(true);
// showHideLanguagesLocalizedButton.add(AttributeAppender.append("style", "cursor: pointer;"));
localizedValueWithButton.add(showHideLanguagesLocalizedButton);
WebMarkupContainer originValueContainer = new WebMarkupContainer(ID_ORIGIN_VALUE_CONTAINER);
originValueContainer.setOutputMarkupId(true);
originValueContainer.add(getInputFieldClassAppenderForContainer());
originValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isEmpty(localizedValue)));
add(originValueContainer);
Label origValueLabel = new Label(ID_ORIG_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.origValue"));
origValueLabel.setOutputMarkupId(true);
origValueLabel.add(new VisibleBehaviour(() -> showFullData));
originValueContainer.add(origValueLabel);
WebMarkupContainer origValueWithButton = new WebMarkupContainer(ID_ORIG_VALUE_WITH_BUTTON);
origValueWithButton.add(getInputFieldClassAppender());
origValueWithButton.setOutputMarkupId(true);
originValueContainer.add(origValueWithButton);
InputPanel origValuePanel;
IModel<String> origValueModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getOrig() : null;
}
@Override
public void setObject(String object) {
PolyString oldModelObject = getModelObject();
if (oldModelObject != null && (oldModelObject.getTranslation() != null || MapUtils.isNotEmpty(oldModelObject.getLang()))) {
getModel().setObject(new PolyString(object, oldModelObject.getNorm(), oldModelObject.getTranslation(), oldModelObject.getLang()));
} else if (StringUtils.isNotBlank(object)) {
getModel().setObject(new PolyString(object));
} else {
getModel().setObject(null);
}
}
@Override
public void detach() {
}
};
if (predefinedValuesLookupTable == null) {
origValuePanel = new TextPanel<>(ID_ORIG_VALUE, origValueModel, String.class, false);
} else {
origValuePanel = new AutoCompleteTextPanel<String>(ID_ORIG_VALUE, origValueModel, String.class, hasValueEnumerationRef, predefinedValuesLookupTable) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<String> getIterator(String input) {
return getPredefinedValuesIterator(input).iterator();
}
};
}
origValuePanel.setOutputMarkupId(true);
origValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
origValueWithButton.add(origValuePanel);
WebMarkupContainer fullDataContainer = new WebMarkupContainer(ID_FULL_DATA_CONTAINER);
fullDataContainer.setOutputMarkupId(true);
fullDataContainer.add(new VisibleBehaviour(() -> showFullData));
add(fullDataContainer);
TextPanel<String> keyValue = new TextPanel<>(ID_KEY_VALUE, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getTranslation() != null ? getModelObject().getTranslation().getKey() : null;
}
@Override
public void setObject(String object) {
if (getModelObject() == null) {
getModel().setObject(new PolyString(""));
}
if (getModelObject().getTranslation() == null) {
getModelObject().setTranslation(new PolyStringTranslationType());
}
getModelObject().getTranslation().setKey(object);
}
@Override
public void detach() {
}
});
keyValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
keyValue.setOutputMarkupId(true);
fullDataContainer.add(keyValue);
IModel<String> langChoiceModel = Model.of();
WebMarkupContainer languageEditorContainer = new WebMarkupContainer(ID_LANGUAGE_EDITOR);
languageEditorContainer.setOutputMarkupId(true);
languageEditorContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getLanguageChoicesModel().getObject())));
fullDataContainer.add(languageEditorContainer);
final DropDownChoicePanel<String> languageChoicePanel = new DropDownChoicePanel<>(ID_LANGUAGES_LIST, langChoiceModel, getLanguageChoicesModel(), true);
languageChoicePanel.setOutputMarkupId(true);
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
removeLanguageValue(currentlySelectedLang.toString());
clearSelectedLanguageValue();
currentlySelectedLang.append(getLanguagesChoicePanel().getBaseFormComponent().getModelObject());
}
});
languageEditorContainer.add(languageChoicePanel);
final TextPanel<String> newLanguageValue = new TextPanel<>(ID_VALUE_TO_ADD, Model.of());
newLanguageValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
languageChoicePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.setOutputMarkupId(true);
languageEditorContainer.add(newLanguageValue);
AjaxLink<Void> addLanguageButton = new AjaxLink<Void>(ID_ADD_LANGUAGE_VALUE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getModel().getObject(), newLanguageValue.getBaseFormComponent().getModelObject());
languageChoicePanel.getModel().setObject(null);
newLanguageValue.getBaseFormComponent().getModel().setObject(null);
clearSelectedLanguageValue();
target.add(PolyStringEditorPanel.this);
}
};
addLanguageButton.add(AttributeAppender.append("style", "cursor: pointer;"));
addLanguageButton.setOutputMarkupId(true);
languageEditorContainer.add(addLanguageButton);
ListView<String> languagesContainer = new ListView<String>(ID_LANGUAGES_REPEATER, getLanguagesListModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> listItem) {
TextPanel<String> languageName = new TextPanel<>(ID_LANGUAGE_NAME, listItem.getModel());
languageName.add(new EnableBehaviour(() -> false));
languageName.setOutputMarkupId(true);
listItem.add(languageName);
TextPanel<String> translation = new TextPanel<>(ID_TRANSLATION, Model.of(getLanguageValueByKey(listItem.getModelObject())));
translation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
translation.setOutputMarkupId(true);
translation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
listItem.add(translation);
AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_LANGUAGE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
removeLanguageValue(listItem.getModelObject());
target.add(PolyStringEditorPanel.this);
}
};
removeButton.setOutputMarkupId(true);
listItem.add(removeButton);
}
};
languagesContainer.setOutputMarkupId(true);
fullDataContainer.add(languagesContainer);
AjaxButton showHideLanguagesButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_ORIG) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesButton.setOutputMarkupId(true);
// showHideLanguagesButton.add(AttributeAppender.append("style", "cursor: pointer;"));
origValueWithButton.add(showHideLanguagesButton);
}
use of com.evolveum.prism.xml.ns._public.types_3.PolyStringTranslationType in project midpoint by Evolveum.
the class ValuePolicyProcessor method testProhibitedValues.
private StringLimitationResult testProhibitedValues(String newPassword, ProhibitedValuesType prohibitedValuesType, ObjectBasedValuePolicyOriginResolver<?> originResolver, String shortDesc, Task task, OperationResult result, List<LocalizableMessage> messages) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
if (prohibitedValuesType == null || originResolver == null) {
return null;
}
StringLimitationResult limitation = new StringLimitationResult();
PolyStringType name = new PolyStringType("prohibited value");
PolyStringTranslationType translation = new PolyStringTranslationType();
translation.setKey("ValuePolicy.prohibitedValueName");
name.setTranslation(translation);
limitation.setName(name);
PolyStringType help = new PolyStringType("");
PolyStringTranslationType helpTranslation = new PolyStringTranslationType();
helpTranslation.setKey("ValuePolicy.prohibitedValue");
help.setTranslation(helpTranslation);
limitation.setHelp(help);
limitation.setSuccess(true);
Consumer<ProhibitedValueItemType> failAction = (prohibitedItemType) -> {
LocalizableMessage msg = new LocalizableMessageBuilder().key("ValuePolicy.prohibitedValue").build();
result.addSubresult(new OperationResult("Prohibited value", OperationResultStatus.FATAL_ERROR, msg));
messages.add(msg);
limitation.setSuccess(false);
};
checkProhibitedValues(newPassword, prohibitedValuesType, originResolver, failAction, shortDesc, task, result);
return limitation;
}
Aggregations