forked from bwerquin/Knowledge-Back-Office
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
42 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
src/main/java/fr/insee/knowledge/service/impl/GenericHierarchyServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,47 @@ | ||
package fr.insee.knowledge.service.impl; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import fr.insee.knowledge.constants.Constants; | ||
import fr.insee.knowledge.dao.generic.DAO; | ||
import fr.insee.knowledge.domain.hierarchy.Hierarchy; | ||
import fr.insee.knowledge.service.GenericHierarchyService; | ||
import org.springframework.core.GenericTypeResolver; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Optional; | ||
|
||
public class GenericHierarchyServiceImpl<T extends Hierarchy> implements GenericHierarchyService<T> { | ||
private DAO<T> hierarchyDAO; | ||
private final DAO<T> hierarchyDAO; | ||
|
||
private final String idHierarchy; | ||
|
||
private final ObjectMapper mapper; | ||
private final String githubFileName; | ||
|
||
private String githubRepository; | ||
|
||
public GenericHierarchyServiceImpl(DAO<T> hierarchyDAO, String githubRepository) { | ||
public GenericHierarchyServiceImpl(DAO<T> hierarchyDAO, String idHierarchy, String githubFileName, String githubRepository) { | ||
this.hierarchyDAO = hierarchyDAO; | ||
this.idHierarchy = idHierarchy; | ||
this.githubFileName = githubFileName; | ||
this.githubRepository = githubRepository; | ||
this.mapper = new ObjectMapper(); | ||
} | ||
|
||
@Override | ||
public T getHierarchy() { | ||
return hierarchyDAO.findById(Constants.idUsersDocument); | ||
return findHierarchyById(idHierarchy); | ||
} | ||
|
||
@Override | ||
public String importHierarchy() throws IOException { | ||
Class<T> tClass = (Class<T>) GenericTypeResolver.resolveTypeArgument(getClass(), GenericHierarchyServiceImpl.class); | ||
T hierarchy = mapper.readValue(new URL(githubRepository + Constants.GithubUserFile), tClass); | ||
T hierarchy = mapper.readValue(new URL(githubRepository + githubFileName), tClass); | ||
return hierarchyDAO.insertOrReplaceOne(hierarchy); | ||
} | ||
|
||
//TODO | ||
@Override | ||
public Boolean isHierarchyExist(String id) { | ||
return null; | ||
public T findHierarchyById(String id) { | ||
return hierarchyDAO.findById(id); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
src/main/java/fr/insee/knowledge/service/impl/HierarchyGsbpmServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
package fr.insee.knowledge.service.impl; | ||
|
||
import fr.insee.knowledge.dao.generic.DAO; | ||
import fr.insee.knowledge.constants.Constants; | ||
import fr.insee.knowledge.dao.impl.HierarchyGsbpmDAOImpl; | ||
import fr.insee.knowledge.domain.hierarchy.HierarchyGsbpm; | ||
import fr.insee.knowledge.domain.hierarchy.HierarchyUser; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class HierarchyGsbpmServiceImpl extends GenericHierarchyServiceImpl<HierarchyGsbpm> { | ||
|
||
public HierarchyGsbpmServiceImpl(HierarchyGsbpmDAOImpl hierarchyDAO, @Value("${fr.insee.knowledge.git.access.rawrepository}") String githubRepository) { | ||
super(hierarchyDAO, githubRepository); | ||
super(hierarchyDAO, Constants.idGsbpmDocument, Constants.GithubGsbpmFile, githubRepository); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters