Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/taskspage
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jan 9, 2020
2 parents 93b1a67 + 92dedcd commit 52e7605
Show file tree
Hide file tree
Showing 80 changed files with 1,918 additions and 1,573 deletions.
8 changes: 7 additions & 1 deletion build-system/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!--
~ Copyright (c) 2010-2019 Evolveum and contributors
~ Copyright (c) 2010-2020 Evolveum and contributors
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -399,6 +399,12 @@
<artifactId>commons-text</artifactId>
<version>1.8</version>
</dependency>
<!-- experimental -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
Expand Up @@ -3278,21 +3278,21 @@ public static <O extends ObjectType> ArchetypePolicyType getArchetypeSpecificati

public static String getIconCssClass(DisplayType displayType){
if (displayType == null || displayType.getIcon() == null){
return null;
return "";
}
return displayType.getIcon().getCssClass();
}

public static String getIconColor(DisplayType displayType){
if (displayType == null || displayType.getIcon() == null){
return null;
return "";
}
return displayType.getIcon().getColor();
}

public static String getDisplayTypeTitle(DisplayType displayType){
if (displayType == null || displayType.getTooltip() == null){
return null;
return "";
}
return displayType.getTooltip().getOrig();
}
Expand Down Expand Up @@ -3368,6 +3368,8 @@ public static <O extends ObjectType> IconType getIconForActivationStatus(O obj){
}
if (LockoutStatusType.LOCKED.equals(((FocusType) obj).getActivation().getLockoutStatus())){
icon.setCssClass(GuiStyleConstants.CLASS_LOCK_STATUS);
} else if (ActivationStatusType.DISABLED.equals(((FocusType) obj).getActivation().getEffectiveStatus())){
icon.setCssClass(GuiStyleConstants.CLASS_ICON_NO_OBJECTS);
}
if (icon.getCssClass() == null){
icon.setCssClass("");
Expand Down
Expand Up @@ -71,7 +71,7 @@ private void initLayout(){
WebComponent icon = new WebComponent(listItems.newChildId());
icon.add(AttributeAppender.append("class", layerIcon.getCssClass()));
if (StringUtils.isNotEmpty(layerIcon.getColor())) {
icon.add(AttributeAppender.append("style", layerIcon.getColor()));
icon.add(AttributeAppender.append("style", "color: " + layerIcon.getColor()));
}
listItems.add(icon);
}
Expand Down
Expand Up @@ -10,6 +10,7 @@
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.wicket.extensions.yui.calendar.DateTimeField;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -49,7 +50,8 @@ public <IW extends ItemWrapper> boolean match(IW wrapper) {
protected Panel getPanel(PrismPropertyPanelContext<XMLGregorianCalendar> panelCtx) {
DatePanel panel = new DatePanel(panelCtx.getComponentId(), panelCtx.getRealValueModel());

DateValidator validator = WebComponentUtil.getRangeValidator(panelCtx.getForm(), SchemaConstants.PATH_ACTIVATION);
Form form = Form.findForm(panelCtx.getForm());
DateValidator validator = WebComponentUtil.getRangeValidator(form, SchemaConstants.PATH_ACTIVATION);
if (ActivationType.F_VALID_FROM.equals(panelCtx.getDefinitionName())) {
validator.setDateFrom((DateTimeField) panel.getBaseFormComponent());
} else if (ActivationType.F_VALID_TO.equals(panelCtx.getDefinitionName())) {
Expand Down
Expand Up @@ -35,6 +35,7 @@ public DateInput(String id, IModel<Date> model) {
@Override
protected void onUpdate(AjaxRequestTarget target){
DateInput.this.setModelObject(computeDateTime());
target.add(DateInput.this);
}
});
}
Expand All @@ -50,6 +51,7 @@ protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel
@Override
protected void onUpdate(AjaxRequestTarget target){
DateInput.this.setModelObject(computeDateTime());
target.add(DateInput.this);
}
});
return dateField;
Expand All @@ -59,7 +61,7 @@ protected void onUpdate(AjaxRequestTarget target){
@Override
public void convertInput() {
super.convertInput();
Date convertedDate = getConvertedInput();
Date convertedDate = computeDateTime();
Date modelDate = getModelObject();
if (convertedDate == null || modelDate == null){
return;
Expand All @@ -86,6 +88,7 @@ protected TextField<Integer> newMinutesTextField(String id, IModel<Integer> mode
@Override
protected void onUpdate(AjaxRequestTarget target){
DateInput.this.setModelObject(computeDateTime());
target.add(DateInput.this);
}
});

Expand All @@ -99,24 +102,26 @@ protected TextField<Integer> newHoursTextField(final String id, IModel<Integer>
@Override
protected void onUpdate(AjaxRequestTarget target){
DateInput.this.setModelObject(computeDateTime());
textField.setConvertedInput(((TextField<Integer>)get(HOURS)).getConvertedInput());
target.add(DateInput.this);
}
});
return textField;
}

public Date computeDateTime() {
Date dateFieldInput = getDate();
if (dateFieldInput == null) {
Date dateFieldInputValue = getDateTextField().getModelObject();
if (dateFieldInputValue == null) {
return null;
}

Integer hoursInput = getHours();
Integer minutesInput = getMinutes();
AM_PM amOrPmInput = getAmOrPm();
Integer hoursInput = ((TextField<Integer>)get(HOURS)).getModelObject();
Integer minutesInput = ((TextField<Integer>)get(MINUTES)).getModelObject();
AM_PM amOrPmInput = ((DropDownChoice<DateTimeField.AM_PM>)get(AM_OR_PM_CHOICE)).getModelObject();

// Get year, month and day ignoring any timezone of the Date object
Calendar cal = Calendar.getInstance();
cal.setTime(dateFieldInput);
cal.setTime(dateFieldInputValue);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH) + 1;
int day = cal.get(Calendar.DAY_OF_MONTH);
Expand All @@ -135,6 +140,8 @@ public Date computeDateTime() {
}

// The date will be in the server's timezone
return newDateInstance(date.getMillis());
Date convertedDateValue = newDateInstance(date.getMillis());
setConvertedInput(convertedDateValue);
return convertedDateValue;
}
}
Expand Up @@ -345,20 +345,20 @@ public static void removeShadowRefEvaluatorValue(ExpressionType expression, Stri
XNode node = raw.getXnode();
if (node instanceof MapXNode && ((MapXNode) node).containsKey(SHADOW_REF_KEY)) {
XNode shadowRefNodes = ((MapXNode) node).get(SHADOW_REF_KEY);
if (shadowRefNodes instanceof MapXNode && shadowRefOid.equals(getShadowRefNodeOid((MapXNode) shadowRefNodes))) {
prismContext.xnodeMutator().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, null);
//todo don't get why while using removeEvaluatorByName no changes are saved
// removeEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
} else if (shadowRefNodes instanceof ListXNode) {
Iterator<? extends XNode> it = ((ListXNode) shadowRefNodes).asList().iterator();
while (it.hasNext()) {
XNode shadowRefNode = it.next();
if (shadowRefNode instanceof MapXNode && shadowRefOid.equals(getShadowRefNodeOid((MapXNode) shadowRefNode))) {
it.remove();
break;
}
}
}
if (shadowRefNodes instanceof MapXNode && shadowRefOid.equals(getShadowRefNodeOid((MapXNode) shadowRefNodes))) {
prismContext.xnodeMutator().putToMapXNode((MapXNode) node, SHADOW_REF_KEY, null);
//todo don't get why while using removeEvaluatorByName no changes are saved
// removeEvaluatorByName(expression, SchemaConstantsGenerated.C_VALUE);
} else if (shadowRefNodes instanceof ListXNode) {
Iterator<? extends XNode> it = ((ListXNode) shadowRefNodes).asList().iterator();
while (it.hasNext()) {
XNode shadowRefNode = it.next();
if (shadowRefNode instanceof MapXNode && shadowRefOid.equals(getShadowRefNodeOid((MapXNode) shadowRefNode))) {
it.remove();
break;
}
}
}
}
}
expression.getExpressionEvaluator().add(element);
Expand Down
Expand Up @@ -190,6 +190,7 @@
}

i.bottom-left-layer-for-column {
font-size: 80% !important;
position: absolute;
left: -40%;
bottom: -15%;
Expand Down
Expand Up @@ -1188,11 +1188,10 @@ public static String debugDump(int indent, LayerType layer, RefinedObjectClassDe
sb.append(",default");
}
if (_this.getKind() != null) {
sb.append(" ").append(_this.getKind().value());
sb.append(",kind=").append(_this.getKind().value());
}
sb.append(",");
if (_this.getIntent() != null) {
sb.append("intent=").append(_this.getIntent());
sb.append(",intent=").append(_this.getIntent());
}
if (layer != null) {
sb.append(",layer=").append(layer);
Expand Down
Expand Up @@ -284,6 +284,20 @@ public static RefinedResourceSchema getRefinedSchema(PrismObject<ResourceType> r
return getRefinedSchema(resource, resource.getPrismContext());
}

public static RefinedResourceSchema getExistingRefinedSchema(PrismObject<ResourceType> resource) {
Object userDataEntry = resource.getUserData(USER_DATA_KEY_REFINED_SCHEMA);
if (userDataEntry != null) {
if (userDataEntry instanceof RefinedResourceSchema) {
return (RefinedResourceSchema)userDataEntry;
} else {
throw new IllegalStateException("Expected RefinedResourceSchema under user data key "+USER_DATA_KEY_REFINED_SCHEMA+
"in "+resource+", but got "+userDataEntry.getClass());
}
} else {
return null;
}
}

/**
* Obtains refined schema for the resource.
*
Expand All @@ -296,19 +310,14 @@ public static RefinedResourceSchema getRefinedSchema(PrismObject<ResourceType> r
throw new SchemaException("Could not get refined schema, resource does not exist.");
}

Object userDataEntry = resource.getUserData(USER_DATA_KEY_REFINED_SCHEMA);
if (userDataEntry != null) {
if (userDataEntry instanceof RefinedResourceSchema) {
return (RefinedResourceSchema)userDataEntry;
} else {
throw new IllegalStateException("Expected RefinedResourceSchema under user data key "+USER_DATA_KEY_REFINED_SCHEMA+
"in "+resource+", but got "+userDataEntry.getClass());
}
RefinedResourceSchema existingRefinedSchema = getExistingRefinedSchema(resource);
if (existingRefinedSchema != null) {
return existingRefinedSchema;
} else {
RefinedResourceSchema refinedSchema = parse(resource, prismContext);
if (resource.isImmutable()) {
throw new IllegalStateException("Trying to set parsed schema on immutable resource: " + resource);
}
RefinedResourceSchema refinedSchema = parse(resource, prismContext);
resource.setUserData(USER_DATA_KEY_REFINED_SCHEMA, refinedSchema);
return refinedSchema;
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2017 Evolveum and contributors
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand All @@ -17,7 +17,7 @@
/**
* Contains the expression that can be part of e.g. prism filters (or other data).
*/
public class ExpressionWrapper implements Cloneable, Serializable {
public class ExpressionWrapper implements Cloneable, Serializable, Freezable {
private static final long serialVersionUID = 1L;

/**
Expand Down Expand Up @@ -56,5 +56,10 @@ public String toString() {
return "ExpressionWrapper(" + PrettyPrinter.prettyPrint(elementName) + ":" + PrettyPrinter.prettyPrint(expression);
}


@Override
public void freeze() {
if (expression instanceof Freezable) {
((Freezable) expression).freeze();
}
}
}
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.prism;

/**
* Something that can be made immutable.
*/
public interface Freezable {

void freeze();
}
@@ -0,0 +1,18 @@
/*
* Copyright (c) 2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/

package com.evolveum.midpoint.prism;

/**
* Experimental.
*/
public class ImmutableUtil {

public static void throwImmutable(Object object) {
throw new IllegalStateException("Object " + object + " couldn't be modified as it is immutable");
}
}
Expand Up @@ -33,7 +33,7 @@
* @author Radovan Semancik
*/
public interface Item<V extends PrismValue, D extends ItemDefinition> extends Itemable, DebugDumpable, Visitable, PathVisitable,
ParentVisitable, Serializable, Revivable {
ParentVisitable, Serializable, Revivable, Freezable {

/**
* Returns applicable definition.
Expand Down Expand Up @@ -551,8 +551,6 @@ static boolean hasNoValues(Item<?, ?> item) {

boolean isImmutable();

void setImmutable();

void checkImmutability();

@NotNull
Expand Down
Expand Up @@ -338,9 +338,6 @@ static <T extends Containerable> List<PrismContainerValue<T>> toPcvList(List<T>
return rv;
}

@Override
void setImmutable();

@Override
Class<?> getRealClass();

Expand Down
Expand Up @@ -183,7 +183,7 @@ void checkConsistenceInternal(Itemable rootItem, boolean requireDefinitions, boo
ConsistencyCheckScope scope);

@Override
void setImmutable();
void freeze();

PrismObject<O> cloneIfImmutable();

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (c) 2010-2020 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
Expand Down Expand Up @@ -95,8 +95,9 @@ public interface PrismPropertyValue<T> extends DebugDumpable, Serializable, Pris
@Override
Class<?> getRealClass();

@SuppressWarnings("unchecked")
@Nullable
@Override
<T> T getRealValue();
T getRealValue();

}

0 comments on commit 52e7605

Please sign in to comment.