-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InstanceSessionResolver to obtain instance entities for instanceS…
…essions when requested by the client.
- Loading branch information
1 parent
2ba97c3
commit 806d681
Showing
7 changed files
with
70 additions
and
13 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
39 changes: 39 additions & 0 deletions
39
...-web-graphql/src/main/java/eu/ill/visa/web/graphql/resolvers/InstanceSessionResolver.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package eu.ill.visa.web.graphql.resolvers; | ||
|
||
import eu.ill.visa.business.services.InstanceService; | ||
import eu.ill.visa.core.domain.filters.InstanceFilter; | ||
import eu.ill.visa.core.entity.Instance; | ||
import eu.ill.visa.web.graphql.types.InstanceSessionType; | ||
import eu.ill.visa.web.graphql.types.InstanceType; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Source; | ||
|
||
import java.util.List; | ||
|
||
|
||
@GraphQLApi | ||
public class InstanceSessionResolver { | ||
|
||
private final InstanceService instanceService; | ||
|
||
@Inject | ||
public InstanceSessionResolver(final InstanceService instanceService) { | ||
this.instanceService = instanceService; | ||
} | ||
|
||
public List<InstanceType> instance(@Source List<InstanceSessionType> instanceSessions) { | ||
final InstanceFilter instanceFilter = new InstanceFilter(); | ||
instanceFilter.setIds(instanceSessions.stream().map(InstanceSessionType::getInstanceId).toList()); | ||
List<Instance> instances = this.instanceService.getAll(instanceFilter); | ||
|
||
return instanceSessions.stream().map(instanceSessionType -> { | ||
return instances.stream().filter(instance -> instance.getId().equals(instanceSessionType.getInstanceId())).findFirst().orElse(null); | ||
}) | ||
.map(instance -> instance == null ? null : new InstanceType(instance)) | ||
.toList(); | ||
} | ||
|
||
|
||
} | ||
|
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