-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#deploy-test-dolly-backend
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 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
45 changes: 45 additions & 0 deletions
45
apps/dolly-backend/src/main/java/no/nav/dolly/mapper/BestillingFullmaktStatusMapper.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,45 @@ | ||
package no.nav.dolly.mapper; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
import no.nav.dolly.domain.jpa.BestillingProgress; | ||
import no.nav.dolly.domain.resultset.RsStatusRapport; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static java.util.Collections.singletonList; | ||
import static no.nav.dolly.domain.resultset.SystemTyper.FULLMAKT; | ||
import static no.nav.dolly.mapper.AbstractRsStatusMiljoeIdentForhold.decodeMsg; | ||
import static no.nav.dolly.util.ListUtil.listOf; | ||
import static org.apache.commons.lang3.StringUtils.isNotBlank; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public final class BestillingFullmaktStatusMapper { | ||
|
||
public static List<RsStatusRapport> buildFullmaktStatusMap(List<BestillingProgress> progressList) { | ||
|
||
Map<String, List<String>> statusMap = new HashMap<>(); | ||
|
||
progressList.forEach(progress -> { | ||
if (isNotBlank(progress.getFullmaktStatus())) { | ||
if (statusMap.containsKey(progress.getFullmaktStatus())) { | ||
statusMap.get(progress.getFullmaktStatus()).add(progress.getIdent()); | ||
} else { | ||
statusMap.put(progress.getFullmaktStatus(), listOf(progress.getIdent())); | ||
} | ||
} | ||
}); | ||
|
||
return statusMap.isEmpty() ? emptyList() : | ||
singletonList(RsStatusRapport.builder().id(FULLMAKT).navn(FULLMAKT.getBeskrivelse()) | ||
.statuser(statusMap.entrySet().stream().map(entry -> RsStatusRapport.Status.builder() | ||
.melding(decodeMsg(entry.getKey())) | ||
.identer(entry.getValue()) | ||
.build()) | ||
.toList()) | ||
.build()); | ||
} | ||
} |
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