@Override public Property getProperty(PropertyChange propertyChange) { ManagedType managedType = typeMapper.getJaversManagedType(propertyChange.getAffectedGlobalId()); return managedType.getProperty(propertyChange.getPropertyName()); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ContainerChange) { ContainerChange that = (ContainerChange) obj; return super.equals(that) && Objects.equals(this.changes, that.changes); } return false; }
public List<PropertyChange> getPropertyChanges() { return (List) changes.stream().filter(c -> c instanceof PropertyChange) .sorted(Comparator.comparing(a -> ((PropertyChange) a).getPropertyNameWithPath())) .collect(Collectors.toList()); }
/** * Selects property changes for given property name */ public List<PropertyChange> getPropertyChanges(final String propertyName) { argumentIsNotNull(propertyName); return (List)getChanges(input -> input instanceof PropertyChange && ((PropertyChange)input).getPropertyName().equals(propertyName)); }
public String getPropertyNameWithPath() { if (getAffectedGlobalId() instanceof ValueObjectId) { return ((ValueObjectId) getAffectedGlobalId()).getFragment() + "." + propertyName; } return propertyName; }
@Override public int hashCode() { return Objects.hash(super.hashCode(), changes); } }
@Override public String toString() { StringBuilder b = new StringBuilder(); getNewObjects().forEach(c -> b.append("* " + c.prettyPrint(valuePrinter) + "\n") ); getObjectsRemoved().forEach(c -> b.append("* " + c.prettyPrint(valuePrinter) + "\n") ); if (!getPropertyChanges().isEmpty()) { b.append("* changes on " + globalId.value() + " :\n"); } getPropertyChanges().forEach(c -> b.append(" - " + c.prettyPrint(valuePrinter).replace("\n", "\n ") + "\n") ); return b.toString(); } }
/** * Selects objects * with changed property for given property name * * @throws JaversException AFFECTED_CDO_IS_NOT_AVAILABLE if diff is restored from repository, */ public List getObjectsWithChangedProperty(String propertyName){ argumentIsNotNull(propertyName); return Lists.transform(getPropertyChanges(propertyName), input -> input.getAffectedObject().<JaversException>orElseThrow(() -> new JaversException(AFFECTED_CDO_IS_NOT_AVAILABLE))); }
private List<Change> filterByPropertyName(List<Change> changes, final QueryParams queryParams) { if (!queryParams.changedProperty().isPresent()){ return changes; } return Lists.positiveFilter(changes, input -> input instanceof PropertyChange && ((PropertyChange) input).getPropertyName().equals(queryParams.changedProperty().get())); }
private boolean isPhantom(final PropertyChange change) { if (hiddenAuditLog == null) { // avoid to retrieve it twice per change final Property property = javers.getProperty(change); hiddenAuditLog = findHiddenAuditLog(property.getMember().getAnnotations()); if (!hiddenAuditLog.isPresent() || !hiddenAuditLog.get().phantom()) { if (ValueObjectId.class.isInstance(change.getAffectedGlobalId())) { final ValueObjectId valueObjectId = ValueObjectId.class.cast(change.getAffectedGlobalId()); String fragment = valueObjectId.getFragment(); while (fragment.contains("/")) { // check if tree is ignored fragment = fragment.replaceAll("/[^/]*", ""); final Property prop = javers.getProperty(new PropertyChange(valueObjectId.getOwnerId(), fragment, empty()) { }); final Optional<HiddenAuditLog> temp = findHiddenAuditLog(prop.getMember().getAnnotations()); if (temp.isPresent() && temp.get().phantom()) { hiddenAuditLog = temp; break; } } } } } return hiddenAuditLog.isPresent() && hiddenAuditLog.get().phantom(); }
@Override public int hashCode() { return Objects.hash(super.hashCode(), this.changes); } }
@Override public void onPropertyChange(final PropertyChange propertyChange) { if (isPhantom(propertyChange)) { return; } builder.append('\'') .append(ofNullable(asPath(propertyChange.getAffectedGlobalId())) .map(s -> s + "/" + propertyChange.getPropertyName()) .orElseGet(propertyChange::getPropertyName)) .append("' changed"); }
protected JsonObject createJsonObject(T change, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.addProperty(CHANGE_TYPE_FIELD, encode(change.getClass())); jsonObject.add(AFFECTED_CDO_ID_FIELD, context.serialize(change.getAffectedGlobalId())); if (change.getCommitMetadata().isPresent()) { jsonObject.add(COMMIT_METADATA, context.serialize(change.getCommitMetadata().get())); } if (change instanceof PropertyChange) { jsonObject.addProperty(PROPERTY_FIELD, ((PropertyChange) change).getPropertyName()); } return jsonObject; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof MapChange) { MapChange that = (MapChange) obj; return super.equals(that) && Objects.equals(this.changes, that.changes); } return false; }
@Override public int hashCode() { return Objects.hash(super.hashCode(), getLeft(), getRight()); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ReferenceChange) { ReferenceChange that = (ReferenceChange) obj; return super.equals(that) && Objects.equals(this.getLeft(), that.getLeft()) && Objects.equals(this.getRight(), that.getRight()); } return false; }
@Override public int hashCode() { return Objects.hash(super.hashCode(), getLeft(), getRight()); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof ValueChange) { ValueChange that = (ValueChange) obj; return super.equals(that) && Objects.equals(this.getLeft(), that.getLeft()) && Objects.equals(this.getRight(), that.getRight()); } return false; }