Esempio n. 1
0
  public Commit createTerminalByGlobalId(String author, GlobalId removedId) {
    Validate.argumentsAreNotNull(author, removedId);

    Optional<CdoSnapshot> previousSnapshot = javersRepository.getLatest(removedId);
    if (previousSnapshot.isEmpty()) {
      throw new JaversException(
          JaversExceptionCode.CANT_DELETE_OBJECT_NOT_FOUND, removedId.value());
    }

    CommitMetadata commitMetadata = nextCommit(author);

    CdoSnapshot terminalSnapshot =
        snapshotFactory.createTerminal(removedId, previousSnapshot.get(), commitMetadata);

    Diff diff = diffFactory.singleTerminal(removedId, commitMetadata);

    return new Commit(commitMetadata, Lists.asList(terminalSnapshot), diff);
  }
Esempio n. 2
0
/** @author bartosz walacik */
public class AnnotationNamesProvider {
  private final Set<String> entityAliases = new HashSet<>();
  private final Set<String> typeNameAliases = new HashSet<>();
  private final Set<String> valueObjectAliases = new HashSet<>();
  private final Set<String> valueAliases = new HashSet<>();
  private final Set<String> transientPropertyAliases = new HashSet<>();

  private final List<AnnotationsNameSpace> namesProviders =
      Lists.immutableListOf(new JaversAnnotationsNamesSpace(), new JPAAnnotationsNameSpace());

  public AnnotationNamesProvider() {

    for (AnnotationsNameSpace provider : namesProviders) {
      entityAliases.addAll(provider.getEntityAliases());
      valueObjectAliases.addAll(provider.getValueObjectAliases());
      valueAliases.addAll(provider.getValueAliases());
      transientPropertyAliases.addAll(provider.getTransientPropertyAliases());
      typeNameAliases.addAll(provider.getTypeNameAliases());
    }
  }

  boolean isTypeName(Annotation ann) {
    return typeNameAliases.contains(ann.annotationType().getSimpleName());
  }

  boolean isEntityAlias(Annotation ann) {
    return entityAliases.contains(ann.annotationType().getSimpleName());
  }

  boolean isValueObjectAlias(Annotation ann) {
    return valueObjectAliases.contains(ann.annotationType().getSimpleName());
  }

  boolean isValueAlias(Annotation ann) {
    return valueAliases.contains(ann.annotationType().getSimpleName());
  }

  public Set<String> getTransientAliases() {
    return Collections.unmodifiableSet(transientPropertyAliases);
  }
}