Skip to content

Commit

Permalink
Merge branch 'release/4.2.0.RELEASE.20220524'
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusHdez960717 committed May 24, 2022
2 parents 5c0ea2f + 618fe0f commit d20f33a
Show file tree
Hide file tree
Showing 45 changed files with 944 additions and 1,475 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* 4.1.1.SNAPSHOT.20220000:
* **GENERAL** :
* **IMPROVEMENT** :raised: : Change `count()` to type `long`.

* 4.1.0.SNAPSHOT.20220410:
* **GENERAL** :
* **IMPROVEMENT** :raised: : Return type of `destroy` & `destroyById` set to void.
Expand Down
17 changes: 14 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {

group = 'dev.root101.clean'

version = '4.1.0.SNAPSHOT.20220410'
version = '4.2.0.RELEASE.20220524'

repositories {
jcenter()
Expand All @@ -14,8 +14,19 @@ repositories {
dependencies{
//validation
implementation 'javax.validation:validation-api:2.0.1.Final'

//runtime de validation, si no da error:
//javax.validation.NoProviderFoundException: Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
implementation 'org.hibernate.validator:hibernate-validator:6.1.0.Final'
implementation 'org.hibernate.validator:hibernate-validator:6.2.3.Final'

//integration with spring
implementation 'org.springframework:spring-web:5.3.20'
implementation 'org.springframework:spring-webmvc:5.3.20'
implementation 'org.springframework:spring-context:5.3.20'
//repo
implementation 'org.springframework.data:spring-data-jpa:2.7.0'

//Jackson
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.3'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
*/
package dev.root101.clean.core.app.domain;

import dev.root101.clean.core.exceptions.ValidationException;
import dev.root101.clean.core.utils.validation.Validable;
import dev.root101.clean.core.utils.validation.ValidationResult;

/**
* Default validate by annotations.
*
Expand All @@ -33,10 +29,6 @@
* @author JesusHdezWaterloo@Github
* @param <ID>
*/
public interface BasicDomainObject<ID> extends DomainObject<ID>, Validable {
public interface BasicDomainObject<ID> extends DomainObject<ID> {

@Override
public default ValidationResult validate() throws ValidationException {
return ValidationResult.validateForAnnotations(this).throwException();
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
*/
package dev.root101.clean.core.app.services;

import dev.root101.clean.core.exceptions.AlreadyRegisteredService;
import dev.root101.clean.core.exceptions.NoneRegisteredService;
import java.util.Objects;

/**
Expand All @@ -34,17 +32,15 @@ private LicenceHandler() {

public static void registerLicenceService(LicenceService newService) {
if (licenceService != null) {
throw new AlreadyRegisteredService("Licence");
System.out.println("Already registered LicenceService");
}
Objects.requireNonNull(newService, "LicenceService can't be null");

licenceService = newService;
}

public static LicenceService getLicenceService() {
if (licenceService == null) {
throw new NoneRegisteredService("Licence");
}
Objects.requireNonNull(licenceService, "LicenceService can't be null");
return licenceService;
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
*/
public interface AbstractUseCase extends PropertyChangeListener {

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener);
public default void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
}

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener);
public default void removePropertyChangeListener(java.beans.PropertyChangeListener listener) {
}

@Override
public default void propertyChange(PropertyChangeEvent evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public interface CRUDUseCase<Domain extends DomainObject<ID>, ID> extends Abstra
* @return findAll().size()
* @throws RuntimeException
*/
public default int count() throws RuntimeException {
public default long count() throws RuntimeException {
return findAll().size();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import dev.root101.clean.core.repo.CRUDRepository;
import dev.root101.clean.core.app.domain.DomainObject;
import dev.root101.clean.core.utils.Licenced;
import dev.root101.clean.core.utils.validation.Validable;
import dev.root101.clean.core.utils.validation.ValidationResult;
import dev.root101.clean.core.utils.validation.ValidationService;
import java.util.List;

/**
Expand Down Expand Up @@ -120,10 +119,10 @@ public List<Domain> findAll() throws RuntimeException {
}

@Override
public int count() throws RuntimeException {
public long count() throws RuntimeException {
firePropertyChange(BEFORE_COUNT, null, null);

int c = crudRepo.count();
long c = crudRepo.count();

firePropertyChange(AFTER_COUNT, null, c);

Expand All @@ -150,10 +149,9 @@ protected void firePropertyChange(String propertyName, Object oldValue, Object n
}
}

private ValidationResult validateDomain(Domain domain) throws RuntimeException {
if (doValidateDomain && domain instanceof Validable validable) {
return validable.validate().throwException();
private void validateDomain(Domain domain) throws RuntimeException {
if (doValidateDomain) {
ValidationService.validateAndThrow(domain);
}
return ValidationResult.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
import static dev.root101.clean.core.app.PropertyChangeConstrains.*;
import dev.root101.clean.core.repo.ReadWriteRepository;
import dev.root101.clean.core.app.domain.DomainObject;
import dev.root101.clean.core.utils.validation.Validable;
import dev.root101.clean.core.utils.validation.ValidationResult;
import dev.root101.clean.core.utils.validation.ValidationService;

/**
*
Expand All @@ -31,6 +30,7 @@
*/
public class DefaultReadWriteUseCase<Domain extends DomainObject, CRUDRepo extends ReadWriteRepository<Domain>> implements ReadWriteUseCase<Domain> {

private final boolean doValidateDomain = true;//for the momento allways enabled
private final boolean doFirePropertyChanges = true;//for the momento allways enabled
protected transient final java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport(this);

Expand Down Expand Up @@ -84,10 +84,9 @@ protected void firePropertyChange(String propertyName, Object oldValue, Object n
}
}

private ValidationResult validateDomain(Domain domain) throws RuntimeException {
if (domain instanceof Validable validable) {
return validable.validate().throwException();
private void validateDomain(Domain domain) throws RuntimeException {
if (doValidateDomain) {
ValidationService.validateAndThrow(domain);
}
return ValidationResult.build();
}
}
Loading

0 comments on commit d20f33a

Please sign in to comment.