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 Sep 11, 2019
2 parents d9b179e + 0e6a0ad commit 27604f3
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 335 deletions.
Expand Up @@ -56,6 +56,14 @@ <h3 style="margin-left: 20px;">
<div wicket:id="propertyTargetType"/>
</td>
</tr>
<tr>
<td>
<wicket:message key="JasperReportParameterProperties.required"/>
</td>
<td>
<div wicket:id="propertyRequired"/>
</td>
</tr>

</table>
</div>
Expand Down
Expand Up @@ -13,6 +13,7 @@
import org.apache.wicket.model.StringResourceModel;

import com.evolveum.midpoint.gui.api.component.BasePanel;
import com.evolveum.midpoint.gui.api.component.form.CheckBoxPanel;
import com.evolveum.midpoint.web.component.AjaxButton;
import com.evolveum.midpoint.web.component.dialog.Popupable;
import com.evolveum.midpoint.web.component.input.TextPanel;
Expand All @@ -26,6 +27,7 @@ public class ParameterPropertiesPopupPanel extends BasePanel<JasperReportParamet
private static final String ID_KEY = "propertyKey";
private static final String ID_LABEL = "propertyLabel";
private static final String ID_TARGET_TYPE = "propertyTargetType";
private static final String ID_REQUIRED = "propertyRequired";
// private static final String ID_MULTIVALUE = "propertyMultivalue";

private static final String ID_BUTTON_UPDATE = "update";
Expand All @@ -42,6 +44,8 @@ private void initLayout() {
addTextPanel(ID_KEY, "key");
addTextPanel(ID_LABEL, "label");
addTextPanel(ID_TARGET_TYPE, "targetType");
CheckBoxPanel multivalue = new CheckBoxPanel(ID_REQUIRED, new PropertyModel<>(getModel(), "mandatory"));
add(multivalue);
// CheckBoxPanel multivalue = new CheckBoxPanel(ID_MULTIVALUE, new PropertyModel<>(getModel(), "multivalue"), Model.of(Boolean.TRUE));
// add(multivalue);

Expand Down
Expand Up @@ -43,6 +43,8 @@ <h3 style="margin-left: 20px;">
<tr wicket:id="paramPanel">
<td>
<label wicket:id="name" />
<span wicket:id="required" style="color: #f00; font-weight: bold;"
wicket:message="title:prismPropertyPanel.required">*</span>
</td>
<td>
<label wicket:id="type" />
Expand Down
Expand Up @@ -63,6 +63,7 @@
import com.evolveum.midpoint.web.component.input.TextPanel;
import com.evolveum.midpoint.web.component.message.FeedbackAlerts;
import com.evolveum.midpoint.web.component.prism.InputPanel;
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;
import com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour;
import com.evolveum.midpoint.web.model.LookupPropertyModel;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
Expand Down Expand Up @@ -180,6 +181,12 @@ private WebMarkupContainer createParameterPanel(final IModel<JasperReportParamet

paramPanel.add(new Label("name", paramDisplay)); // use display name rather than property name

WebMarkupContainer required = new WebMarkupContainer("required");
JasperReportParameterPropertiesDto properties = parameterModel.getObject().getProperties();
boolean mandatory = (properties != null && properties.getMandatory());
required.add(new VisibleBehaviour(() -> mandatory));
paramPanel.add(required);

String paramClass = new PropertyModel<String>(parameterModel, "nestedTypeAsString").getObject();
if (StringUtils.isBlank(paramClass)) {
paramClass = new PropertyModel<String>(parameterModel, "typeAsString").getObject();
Expand All @@ -193,7 +200,7 @@ private WebMarkupContainer createParameterPanel(final IModel<JasperReportParamet

@Override
protected void populateItem(ListItem<JasperReportValueDto> item) {
item.add(createInputMarkup(item.getModel(), parameterModel.getObject()));
item.add(createInputMarkup(item.getModel(), parameterModel.getObject(), mandatory, paramDisplay));

}

Expand All @@ -204,12 +211,14 @@ protected void populateItem(ListItem<JasperReportValueDto> item) {
return paramPanel;
}

private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param) {
private WebMarkupContainer createInputMarkup(final IModel<JasperReportValueDto> valueModel, JasperReportParameterDto param, boolean required, IModel<String> name) {
param.setEditing(true);
WebMarkupContainer paramValueMarkup = new WebMarkupContainer("valueMarkup");
paramValueMarkup.setOutputMarkupId(true);

InputPanel input = createTypedInputPanel("inputValue", valueModel, "value", param);
input.getBaseFormComponent().setRequired(required);
input.getBaseFormComponent().setLabel(name);
paramValueMarkup.add(input);

//buttons
Expand Down
Expand Up @@ -15,6 +15,7 @@ public class JasperReportParameterPropertiesDto implements Serializable{
private static final String PROPERTY_LABEL = "label";
private static final String PROPERTY_TARGET_TYPE = "targetType";
private static final String PROPERTY_MULTIVALUE = "multivalue";
private static final String MANDATORY_KEY = "mandatory";


private JRPropertiesMap propertiesMap;
Expand Down Expand Up @@ -87,6 +88,25 @@ public void setKey(String key) {

propertiesMap.setProperty(PROPERTY_KEY, key);
}

public boolean getMandatory() {
if (propertiesMap == null) {
return false;
}
String isMandatory = propertiesMap.getProperty(MANDATORY_KEY);
if (isMandatory != null && Boolean.valueOf(isMandatory)) {
return true;
}
return false;
}

public void setMandatory(boolean isMandatory) {
if (propertiesMap == null) {
propertiesMap = new JRPropertiesMap();
}

propertiesMap.setProperty(MANDATORY_KEY, String.valueOf(isMandatory));
}

public JRPropertiesMap getPropertiesMap() {
return propertiesMap;
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -1491,11 +1491,9 @@ th.countLabel{
table-layout: fixed; // fix for text in cells
}

@-moz-document url-prefix() {
.shopping-cart-icon > .badge { //fix for bug in firefox
.shopping-cart-icon > .badge {
margin-left: -10px !important;
}
}

@media (max-width: 767px) {
.content-wrapper {
Expand Down
Expand Up @@ -2286,13 +2286,15 @@
those hardcoded lifecycle states need to be explicitly defined in the state model
and the forcedActivationStatus property shoule be left undefined.
</p>
<!-- TODO: should be replaced by assignmentSelector later -->
</xsd:documentation>
<xsd:appinfo>
<a:since>3.8</a:since>
<a:displayName>LifecycleStateType.activeAssignments</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<!-- TODO: MID-5741: assignmentSelector that can be used to selectively activate/deactivate assignments based on their targetType, targetArchetype, relation, subtype and so on -->
<!-- TODO: activationStatus -->
<xsd:element name="entryAction" type="tns:LifecycleStateActionType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
Expand Down
Expand Up @@ -28,6 +28,7 @@
import com.evolveum.midpoint.schema.util.*;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.LocalizableMessage;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.util.logging.LoggingUtils;

Expand Down Expand Up @@ -547,7 +548,15 @@ public static <F extends ObjectType> boolean evaluateIterationCondition(LensCont
*/
public static boolean isAssignmentValid(AssignmentHolderType focus, AssignmentType assignmentType, XMLGregorianCalendar now,
ActivationComputer activationComputer, LifecycleStateModelType focusStateModel) {
String focusLifecycleState = focus.getLifecycleState();
ObjectReferenceType targetRef = assignmentType.getTargetRef();
if (targetRef != null) {
if (QNameUtil.match(ArchetypeType.COMPLEX_TYPE, targetRef.getType())) {
// Archetype assignments are always valid, even in non-valid lifecycle states.
// The object cannot lose its (arche)type.
return true;
}
}
String focusLifecycleState = focus.getLifecycleState();

if (!activationComputer.lifecycleHasActiveAssignments(focusLifecycleState, focusStateModel)) {
return false;
Expand Down
Expand Up @@ -84,6 +84,9 @@ public class TestArchetypes extends AbstractArchetypesTest {

public static final File USER_MEATHOOK_FILE = new File(TEST_DIR, "user-meathook.xml");
protected static final String USER_MEATHOOK_OID = "f79fc10e-78a8-11e9-92ec-cf427cb6e7a0";

public static final File USER_WANNABE_FILE = new File(TEST_DIR, "user-wannabe.xml");
protected static final String USER_WANNABE_OID = "28038d88-d3eb-11e9-87fb-cff5e050b6f9";

public static final File ROLE_EMPLOYEE_BASE_FILE = new File(TEST_DIR, "role-employee-base.xml");
protected static final String ROLE_EMPLOYEE_BASE_OID = "e869d6c4-f6ef-11e8-b51f-df3e51bba129";
Expand Down Expand Up @@ -747,6 +750,42 @@ public void test140AddMeathookContractor() throws Exception {
.end()
.assertEmployeeNumber(CONTRACTOR_EMPLOYEE_NUMBER);
}

/**
* Add "Wanabe" user with an contractor archetype, but in DRAFT lifecycle state.
* Even though assignments are not active in draft state, archetype assignment should be active anyway.
* MID-5583
*/
@Test
public void test150AddWannabe() throws Exception {
final String TEST_NAME = "test150AddWannabe";
displayTestTitle(TEST_NAME);

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

// WHEN
displayWhen(TEST_NAME);

addObject(USER_WANNABE_FILE, task, result);

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

assertUserAfter(USER_WANNABE_OID)
.assertLifecycleState(SchemaConstants.LIFECYCLE_DRAFT)
.assignments()
.assertAssignments(1)
.assertArchetype(ARCHETYPE_CONTRACTOR_OID)
.end()
.assertArchetypeRef(ARCHETYPE_CONTRACTOR_OID)
.roleMembershipRefs()
.assertRoleMemberhipRefs(1)
.assertArchetype(ARCHETYPE_CONTRACTOR_OID)
.end()
.assertEmployeeNumber(CONTRACTOR_EMPLOYEE_NUMBER);
}

@Test
public void test200AssignJackBarbossaArchetypeEmployee() throws Exception {
Expand Down
22 changes: 22 additions & 0 deletions model/model-intest/src/test/resources/archetypes/user-wannabe.xml
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2019 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<user oid="28038d88-d3eb-11e9-87fb-cff5e050b6f9"
xmlns='http://midpoint.evolveum.com/xml/ns/public/common/common-3'
xmlns:c='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>wannabe</name>
<lifecycleState>draft</lifecycleState>
<assignment>
<targetRef oid="3911cac2-78a6-11e9-8b5e-4b5bdb0c81d5" type="ArchetypeType"/> <!-- Contractor -->
</assignment>
<fullName>Contractor Wannabe</fullName>
</user>
Expand Up @@ -1669,7 +1669,7 @@ private Collection<? extends ItemDelta> extractRepoShadowChanges(ProvisioningCon
QName attrName = itemDelta.getElementName();
if (objectClassDefinition.isSecondaryIdentifier(attrName)
|| (objectClassDefinition.getAllIdentifiers().size() == 1 && objectClassDefinition.isPrimaryIdentifier(attrName))) {
// Change of secondary identifier means object rename. We also need to change $shadow/name
// Change of secondary identifier, or primary identifier when it is only one, means object rename. We also need to change $shadow/name
// TODO: change this to displayName attribute later
String newName = null;
if (itemDelta.getValuesToReplace() != null && !itemDelta.getValuesToReplace().isEmpty()) {
Expand Down

0 comments on commit 27604f3

Please sign in to comment.