Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/perf-schema…
Browse files Browse the repository at this point in the history
…transform
  • Loading branch information
tonydamage committed May 27, 2021
2 parents 98286f1 + a2e9412 commit 5f2b4b5
Show file tree
Hide file tree
Showing 133 changed files with 4,211 additions and 1,475 deletions.
2 changes: 0 additions & 2 deletions config/sql/postgresql-4.3-all.sql
Expand Up @@ -1399,5 +1399,3 @@ create index idx_qrtz_ft_j_g on qrtz_fired_triggers(SCHED_NAME,JOB_NAME,JOB_GROU
create index idx_qrtz_ft_jg on qrtz_fired_triggers(SCHED_NAME,JOB_GROUP);
create index idx_qrtz_ft_t_g on qrtz_fired_triggers(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP);
create index idx_qrtz_ft_tg on qrtz_fired_triggers(SCHED_NAME,TRIGGER_GROUP);

commit;
26 changes: 12 additions & 14 deletions infra/common/src/main/java/com/evolveum/midpoint/common/Clock.java
Expand Up @@ -27,8 +27,8 @@ public class Clock {

private static final Trace LOGGER = TraceManager.getTrace(Clock.class);

private Long override = null;
private Long overrideOffset = null;
volatile private Long override = null;
volatile private Long overrideOffset = null;

public long currentTimeMillis() {
long time;
Expand Down Expand Up @@ -66,11 +66,10 @@ public boolean isFuture(XMLGregorianCalendar date) {
}

public void override(long overrideTimestamp) {
LOGGER.info("Clock override: {}", override);
Long originalOverride = this.override;
this.override = overrideTimestamp;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Clock current time: {}", currentTimeXMLGregorianCalendar());
}
LOGGER.info("Clock override changed from {} to {}", originalOverride, this.override);
LOGGER.debug("Clock current time: {}", currentTimeXMLGregorianCalendar());
}

public void override(XMLGregorianCalendar overrideTimestamp) {
Expand Down Expand Up @@ -99,24 +98,23 @@ public void overrideDuration(Duration duration) {
* Extends offset on top of existing offset.
*/
public void overrideDuration(Long offsetMillis) {
if (overrideOffset == null) {
overrideOffset = offsetMillis;
Long originalOverrideOffset = this.overrideOffset;
if (originalOverrideOffset == null) {
this.overrideOffset = offsetMillis;
} else {
overrideOffset = overrideOffset + offsetMillis;
this.overrideOffset = originalOverrideOffset + offsetMillis;
}
LOGGER.info("Clock override offset changed from {} to {}", originalOverrideOffset, this.overrideOffset);
}

public void overrideOffset(Long offsetMillis) {
this.overrideOffset = offsetMillis;
}

public void resetOverride() {
LOGGER.info("Clock override reset");
this.override = null;
this.overrideOffset = null;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Clock current time: {}", currentTimeXMLGregorianCalendar());
}
LOGGER.info("Clock override and override offset were reset");
LOGGER.debug("Clock current time: {}", currentTimeXMLGregorianCalendar());
}

}
@@ -1,12 +1,15 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 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.impl.query;

import java.util.Objects;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.*;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.path.ItemPath;
Expand All @@ -16,7 +19,6 @@
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.SchemaException;
import org.jetbrains.annotations.NotNull;

/**
* TODO think about creating abstract ItemFilter (ItemRelatedFilter) for this filter and ValueFilter.
Expand All @@ -27,10 +29,10 @@
public final class ExistsFilterImpl extends ObjectFilterImpl implements ExistsFilter {

@NotNull private final ItemPath fullPath;
private final ItemDefinition definition;
private final ItemDefinition<?> definition;
private ObjectFilter filter;

private ExistsFilterImpl(@NotNull ItemPath fullPath, ItemDefinition definition, ObjectFilter filter) {
private ExistsFilterImpl(@NotNull ItemPath fullPath, ItemDefinition<?> definition, ObjectFilter filter) {
this.fullPath = fullPath;
this.definition = definition;
this.filter = filter;
Expand Down Expand Up @@ -65,18 +67,17 @@ protected void performFreeze() {
}

public static <C extends Containerable> ExistsFilter createExists(ItemPath itemPath, PrismContainerDefinition<C> containerDef,
ObjectFilter filter) throws SchemaException {
ItemDefinition itemDefinition = FilterImplUtil.findItemDefinition(itemPath, containerDef);
ObjectFilter filter) throws SchemaException {
ItemDefinition<?> itemDefinition = FilterImplUtil.findItemDefinition(itemPath, containerDef);
return new ExistsFilterImpl(itemPath, itemDefinition, filter);
}

public static <C extends Containerable> ExistsFilter createExists(ItemPath itemPath, Class<C> clazz, PrismContext prismContext,
ObjectFilter filter) {
ItemDefinition itemDefinition = FilterImplUtil.findItemDefinition(itemPath, clazz, prismContext);
ObjectFilter filter) {
ItemDefinition<?> itemDefinition = FilterImplUtil.findItemDefinition(itemPath, clazz, prismContext);
return new ExistsFilterImpl(itemPath, itemDefinition, filter);
}

@SuppressWarnings("CloneDoesntCallSuperClone")
@Override
public ExistsFilterImpl clone() {
ObjectFilter f = filter != null ? filter.clone() : null;
Expand Down Expand Up @@ -111,10 +112,10 @@ public boolean match(PrismContainerValue value, MatchingRuleRegistry matchingRul
@Override
public void checkConsistence(boolean requireDefinitions) {
if (fullPath.isEmpty()) {
throw new IllegalArgumentException("Null or empty path in "+this);
throw new IllegalArgumentException("Null or empty path in " + this);
}
if (requireDefinitions && definition == null) {
throw new IllegalArgumentException("Null definition in "+this);
throw new IllegalArgumentException("Null definition in " + this);
}
// null subfilter is legal. It means "ALL".
if (filter != null) {
Expand All @@ -132,7 +133,7 @@ public String debugDump(int indent) {
DebugUtil.indentDebugDump(sb, indent + 1);
sb.append("DEF: ");
if (getDefinition() != null) {
sb.append(getDefinition().toString());
sb.append(getDefinition());
} else {
sb.append("null");
}
Expand All @@ -145,13 +146,11 @@ public String debugDump(int indent) {

@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("EXISTS(");
sb.append(PrettyPrinter.prettyPrint(fullPath));
sb.append(",");
sb.append(filter);
sb.append(")");
return sb.toString();
return "EXISTS("
+ PrettyPrinter.prettyPrint(fullPath)
+ ", "
+ filter
+ ")";
}

@Override
Expand All @@ -164,16 +163,20 @@ public void accept(Visitor visitor) {

@Override
public boolean equals(Object o, boolean exact) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

ExistsFilterImpl that = (ExistsFilterImpl) o;

if (!fullPath.equals(that.fullPath, exact)) return false;
if (exact) {
if (definition != null ? !definition.equals(that.definition) : that.definition != null) {
return false;
}
if (!fullPath.equals(that.fullPath, exact)) {
return false;
}
if (exact && !Objects.equals(definition, that.definition)) {
return false;
}
return filter != null ? filter.equals(that.filter, exact) : that.filter == null;
}
Expand Down
@@ -1,26 +1,25 @@
/*
* Copyright (c) 2010-2018 Evolveum and contributors
* Copyright (C) 2010-2021 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.impl.query;

import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;

import com.google.common.collect.ImmutableList;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.prism.ExpressionWrapper;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.match.MatchingRuleRegistry;
import com.evolveum.midpoint.prism.query.FullTextFilter;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.google.common.collect.ImmutableList;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
import java.util.stream.Collectors;

public final class FullTextFilterImpl extends ObjectFilterImpl implements FullTextFilter {

Expand All @@ -35,11 +34,11 @@ private FullTextFilterImpl(ExpressionWrapper expression) {
this.expression = expression;
}

public static FullTextFilter createFullText(Collection<String> values){
public static FullTextFilter createFullText(Collection<String> values) {
return new FullTextFilterImpl(values);
}

public static FullTextFilter createFullText(String... values){
public static FullTextFilter createFullText(String... values) {
return new FullTextFilterImpl(Arrays.asList(values));
}

Expand Down Expand Up @@ -78,14 +77,14 @@ protected void performFreeze() {
@Override
public void checkConsistence(boolean requireDefinitions) {
if (values == null) {
throw new IllegalArgumentException("Null 'values' in "+this);
throw new IllegalArgumentException("Null 'values' in " + this);
}
if (values.isEmpty()) {
throw new IllegalArgumentException("No values in "+this);
throw new IllegalArgumentException("No values in " + this);
}
for (String value: values) {
for (String value : values) {
if (StringUtils.isBlank(value)) {
throw new IllegalArgumentException("Empty value in "+this);
throw new IllegalArgumentException("Empty value in " + this);
}
}
}
Expand All @@ -98,7 +97,7 @@ public String debugDump(int indent) {
if (values != null) {
sb.append("\n");
for (String value : values) {
DebugUtil.indentDebugDump(sb, indent+1);
DebugUtil.indentDebugDump(sb, indent + 1);
sb.append(value);
sb.append("\n");
}
Expand All @@ -113,7 +112,7 @@ public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("FULLTEXT: ");
if (values != null) {
sb.append(values.stream().collect(Collectors.joining("; ")));
sb.append(String.join("; ", values));
}
return sb.toString();
}
Expand All @@ -132,8 +131,12 @@ public boolean match(PrismContainerValue value, MatchingRuleRegistry matchingRul

@Override
public boolean equals(Object o, boolean exact) {
if (this == o) return true;
if (!(o instanceof FullTextFilterImpl)) return false;
if (this == o) {
return true;
}
if (!(o instanceof FullTextFilterImpl)) {
return false;
}
FullTextFilterImpl that = (FullTextFilterImpl) o;
return Objects.equals(values, that.values) &&
Objects.equals(expression, that.expression);
Expand Down

0 comments on commit 5f2b4b5

Please sign in to comment.