Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Aug 28, 2019
2 parents e3572da + 892cfd0 commit fd2e8d2
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 4 deletions.
Expand Up @@ -62,6 +62,7 @@ public int getOrder() {
@Override
protected PrismReferenceValue createNewValue(PrismReference item) throws SchemaException {
PrismReferenceValue prv = getPrismContext().itemFactory().createReferenceValue();
item.getValues().add(prv);
return prv;
}

Expand Down
Expand Up @@ -275,6 +275,22 @@ private <T> void cleanupEmptyValues(Item item) {
}
}
}

if (item instanceof PrismReference) {
PrismReference ref = (PrismReference) item;
List<PrismReferenceValue> values = ref.getValues();
if (values == null || values.isEmpty()) {
return;
}

Iterator<PrismReferenceValue> iterator = values.iterator();
while (iterator.hasNext()) {
PrismReferenceValue rVal = iterator.next();
if (rVal == null || rVal.isEmpty()) {
iterator.remove();
}
}
}
}

@Override
Expand Down
Expand Up @@ -50,6 +50,8 @@ public void setRealValue(T realValueReferencable) {
value.setTargetType(realValue.getTargetType());
value.setRelation(realValue.getRelation());
value.setFilter(realValue.getFilter());

setStatus(ValueStatus.MODIFIED);
}

public boolean isEditEnabled() {
Expand Down
Expand Up @@ -72,6 +72,7 @@ public class PolyStringEditorPanel extends BasePanel<PolyString>{
private static final String ID_REMOVE_LANGUAGE_BUTTON = "removeLanguageButton";

private boolean showFullData = false;
private final StringBuilder currentlySelectedLang = new StringBuilder();

public PolyStringEditorPanel(String id, IModel<PolyString> model){
super(id, model);
Expand Down Expand Up @@ -202,14 +203,26 @@ public void detach() {
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<String>(ID_LANGUAGES_LIST, Model.of(),
final DropDownChoicePanel<String> languageChoicePanel = new DropDownChoicePanel<String>(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<String>(ID_VALUE_TO_ADD, Model.of());
Expand Down Expand Up @@ -249,6 +262,7 @@ public void onClick(AjaxRequestTarget target) {
newLanguageValue.getBaseFormComponent().getModelObject());
languageChoicePanel.getModel().setObject(null);
newLanguageValue.getBaseFormComponent().getModel().setObject(null);
clearSelectedLanguageValue();
target.add(PolyStringEditorPanel.this);
}
};
Expand Down Expand Up @@ -334,10 +348,12 @@ private IModel<List<String>> getLanguageChoicesModel(){
@Override
public List<String> getObject() {
List<String> allLanguagesList = new ArrayList<>();
String currentlySelectedLang = getLanguagesChoicePanel().getBaseFormComponent().getModel().getObject();
MidPointApplication.AVAILABLE_LOCALES.forEach(locale -> {
String localeValue = locale.getLocale().getLanguage();
if (!isPolyStringLangNotNull()) {
allLanguagesList.add(locale.getLocale().getLanguage());
} else if (!languageExists(locale.getLocale().getLanguage())){
allLanguagesList.add(localeValue);
} else if (!languageExists(localeValue) || localeValue.equals(currentlySelectedLang)){
allLanguagesList.add(locale.getLocale().getLanguage());
}
});
Expand Down Expand Up @@ -452,4 +468,8 @@ private String getLanguageValueByKey(String key){
private DropDownChoicePanel<String> getLanguagesChoicePanel(){
return (DropDownChoicePanel<String>)get(ID_FULL_DATA_CONTAINER).get(ID_LANGUAGE_EDITOR).get(ID_LANGUAGES_LIST);
}

private void clearSelectedLanguageValue(){
currentlySelectedLang.delete(0, currentlySelectedLang.length());
}
}
Expand Up @@ -25,6 +25,7 @@
import javax.xml.namespace.QName;

import org.apache.wicket.Component;
import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
Expand Down Expand Up @@ -353,7 +354,9 @@ protected PrismObjectWrapper<TaskType> loadObjectWrapper(PrismObject<TaskType> o
wrapper = owf.createObjectWrapper(object, ItemStatus.NOT_CHANGED, context);
// wrapper = owf.createObjectWrapper("pageAdminFocus.focusDetails", null, object, null, null, ContainerStatus.MODIFYING, task);
} catch (SchemaException e) {
throw new SystemException(e.getMessage(), e);
result.recordFatalError(e.getMessage(), e);
showResult(result, false);
throw new RestartResponseException(PageTasks.class);
}
}
showResult(result, false);
Expand Down
Expand Up @@ -103,6 +103,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
setDefaultObjectTemplate(RoleType.COMPLEX_TYPE, SUBTYPE_GROUP, OBJECT_TEMPLATE_ROLE_GROUP_OID, initResult);

addObject(TASK_DUMMY_DIR_LIVESYNC_FILE);

importObjectFromFile(USER_MANCOMB_FILE, initResult);
}

@Test
Expand Down Expand Up @@ -541,6 +543,34 @@ public void test159JackUnassignDirAccount() throws Exception {
.assertNoMembers();
}

/**
* MID-5635
*/
@Test
public void test200MancombAssignAccount() throws Exception {
final String TEST_NAME = "test200MancombAssignAccount";
displayTestTitle(TEST_NAME);

Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

// WHEN
displayWhen(TEST_NAME);
assignAccountToUser(USER_MANCOMB_OID, RESOURCE_DUMMY_DIR_OID, "default", task, result);

// THEN
displayThen(TEST_NAME);
assertSuccess(result);

display("dir after", getDummyResourceDir());
assertUserAfter(USER_MANCOMB_OID)
.assignments()
.assertAssignments(1);

assertDummyAccount(RESOURCE_DUMMY_DIR_NAME, USER_MANCOMB_USERNAME);

}

private String groupRoleName(String groupName) {
return "group:"+groupName;
}
Expand Down
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2014 Evolveum
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<user oid="8e3a3770-cc60-11e8-8354-a7bb150473c1"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:t='http://prism.evolveum.com/xml/ns/public/types-3'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:piracy='http://midpoint.evolveum.com/xml/ns/samples/piracy'>
<name>mancomb</name>

<fullName>Mancomb Seepgood</fullName>
<givenName>Mancomb</givenName>
<familyName>Seepgood</familyName>

</user>

0 comments on commit fd2e8d2

Please sign in to comment.