Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.burningwave.core.classes.GenericSourceGenerator;
import org.burningwave.core.classes.TypeDeclarationSourceGenerator;
import org.burningwave.core.classes.UnitSourceGenerator;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import dev.sassine.api.structure.export.builder.factory.Factory;
Expand All @@ -25,8 +26,6 @@ public class RepositoryFactory implements Factory {

private static final Logger log = getLogger();

private static final String PACKAGE_JPAREPOSITORY = "org.springframework.data.jpa.repository.JpaRepository";
private static final String CLASSNAME_JPAREPOSITORY = "JpaRepository";
private static final String DOT_REPOSITORY = ".repository";
private static final String ENTITY_REPOSITORY = "EntityRepository";
private static final String ENTITY = "Entity";
Expand All @@ -39,16 +38,15 @@ public void execute(EntityModel entityModel, boolean isAutoGenerated, String nam
ClassSourceGenerator interfaceClass = this.buildClassSource(entityModel, nameClass);
log.debug("InterfaceRepository builded");
importEntityClass(nameClass, packageName, gen);
gen.addImport(PACKAGE_JPAREPOSITORY);
gen.addClass(interfaceClass);
store(gen);
log.debug("Repository EntityClass ({}) stored", nameClass);
}

private ClassSourceGenerator buildClassSource(EntityModel entityModel, String nameClass) {
return ClassSourceGenerator
.createInterface(TypeDeclarationSourceGenerator.create(ENTITY_REPOSITORY))
.expands(TypeDeclarationSourceGenerator.create(CLASSNAME_JPAREPOSITORY)
.createInterface(TypeDeclarationSourceGenerator.create(nameClass.concat(ENTITY_REPOSITORY)))
.expands(TypeDeclarationSourceGenerator.create(JpaRepository.class)
.addGeneric(GenericSourceGenerator.create(nameClass.concat(ENTITY)))
.addGeneric(GenericSourceGenerator.create(this.getIdClassType(entityModel))))
.addModifier(PUBLIC)
Expand Down