-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2586 from objectcomputing/feature-2571/merit-eval…
…uation-report Feature 2571/merit evaluation report
- Loading branch information
Showing
34 changed files
with
2,621 additions
and
16 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
53 changes: 53 additions & 0 deletions
53
server/src/main/java/com/objectcomputing/checkins/services/reports/CSVProcessor.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,53 @@ | ||
package com.objectcomputing.checkins.services.reports; | ||
|
||
import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; | ||
import com.objectcomputing.checkins.exceptions.BadArgException; | ||
|
||
import org.apache.commons.csv.CSVFormat; | ||
import org.apache.commons.csv.CSVParser; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.IOException; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatterBuilder; | ||
import java.time.format.DateTimeParseException; | ||
import java.time.temporal.ChronoField; | ||
import java.util.List; | ||
|
||
abstract class CSVProcessor { | ||
|
||
public void load(MemberProfileRepository memberProfileRepository, | ||
ByteBuffer dataSource) throws IOException, | ||
BadArgException { | ||
ByteArrayInputStream stream = new ByteArrayInputStream(dataSource.array()); | ||
InputStreamReader input = new InputStreamReader(stream); | ||
CSVParser csvParser = CSVFormat.RFC4180 | ||
.builder() | ||
.setHeader().setSkipHeaderRecord(true) | ||
.setIgnoreSurroundingSpaces(true) | ||
.setNullString("") | ||
.build() | ||
.parse(input); | ||
loadImpl(memberProfileRepository, csvParser); | ||
} | ||
|
||
protected abstract void loadImpl(MemberProfileRepository memberProfileRepository, CSVParser csvParser) throws BadArgException; | ||
|
||
protected LocalDate parseDate(String date) { | ||
List<String> formatStrings = List.of("yyyy", "M/d/yyyy"); | ||
for(String format: formatStrings) { | ||
try { | ||
return LocalDate.parse(date, | ||
new DateTimeFormatterBuilder() | ||
.appendPattern(format) | ||
.parseDefaulting(ChronoField.MONTH_OF_YEAR, 1) | ||
.parseDefaulting(ChronoField.DAY_OF_MONTH, 1) | ||
.toFormatter()); | ||
} catch(DateTimeParseException ex) { | ||
} | ||
} | ||
return null; | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
server/src/main/java/com/objectcomputing/checkins/services/reports/CompensationHistory.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,70 @@ | ||
package com.objectcomputing.checkins.services.reports; | ||
|
||
import com.objectcomputing.checkins.services.memberprofile.MemberProfile; | ||
import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; | ||
import com.objectcomputing.checkins.exceptions.BadArgException; | ||
|
||
import org.apache.commons.csv.CSVParser; | ||
import org.apache.commons.csv.CSVRecord; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
public class CompensationHistory extends CSVProcessor { | ||
|
||
public record Compensation( | ||
UUID memberId, | ||
LocalDate startDate, | ||
float amount | ||
) { | ||
} | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CompensationHistory.class); | ||
private final List<Compensation> history = new ArrayList<>(); | ||
|
||
@Override | ||
protected void loadImpl(MemberProfileRepository memberProfileRepository, | ||
CSVParser csvParser) throws BadArgException { | ||
history.clear(); | ||
for (CSVRecord csvRecord : csvParser) { | ||
try { | ||
String emailAddress = csvRecord.get("emailAddress"); | ||
Optional<MemberProfile> memberProfile = | ||
memberProfileRepository.findByWorkEmail(emailAddress); | ||
if (memberProfile.isPresent()) { | ||
LocalDate date = parseDate(csvRecord.get("startDate")); | ||
if (date == null) { | ||
LOG.error("Unable to parse date: " + csvRecord.get("startDate")); | ||
} else { | ||
Compensation comp = new Compensation( | ||
memberProfile.get().getId(), | ||
date, | ||
Float.parseFloat(csvRecord.get("compensation") | ||
.replaceAll("[^\\d\\.,]", ""))); | ||
history.add(comp); | ||
} | ||
} else { | ||
LOG.error("Unable to find a profile for " + emailAddress); | ||
} | ||
} catch(IllegalArgumentException ex) { | ||
throw new BadArgException("Unable to parse the compensation history"); | ||
} | ||
} | ||
} | ||
|
||
public List<Compensation> getHistory(UUID memberId) { | ||
return history.stream() | ||
.filter(entry -> entry.memberId().equals(memberId)) | ||
.toList(); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
server/src/main/java/com/objectcomputing/checkins/services/reports/CurrentInformation.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,70 @@ | ||
package com.objectcomputing.checkins.services.reports; | ||
|
||
import com.objectcomputing.checkins.exceptions.NotFoundException; | ||
import com.objectcomputing.checkins.services.memberprofile.MemberProfile; | ||
import com.objectcomputing.checkins.services.memberprofile.MemberProfileRepository; | ||
import com.objectcomputing.checkins.exceptions.BadArgException; | ||
|
||
import org.apache.commons.csv.CSVParser; | ||
import org.apache.commons.csv.CSVRecord; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.Optional; | ||
|
||
public class CurrentInformation extends CSVProcessor { | ||
|
||
public record Information( | ||
UUID memberId, | ||
float salary, | ||
String range, | ||
String nationalRange, | ||
String biography, | ||
String commitments | ||
) { | ||
} | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CurrentInformation.class); | ||
private final List<Information> information = new ArrayList<>(); | ||
|
||
@Override | ||
protected void loadImpl(MemberProfileRepository memberProfileRepository, | ||
CSVParser csvParser) throws BadArgException { | ||
information.clear(); | ||
for (CSVRecord csvRecord : csvParser) { | ||
try { | ||
String emailAddress = csvRecord.get("emailAddress"); | ||
Optional<MemberProfile> memberProfile = | ||
memberProfileRepository.findByWorkEmail(emailAddress); | ||
if (memberProfile.isPresent()) { | ||
Information comp = new Information( | ||
memberProfile.get().getId(), | ||
Float.parseFloat(csvRecord.get("salary") | ||
.replaceAll("[^\\d\\.,]", "")), | ||
csvRecord.get("range"), | ||
csvRecord.get("nationalRange"), | ||
csvRecord.get("biography"), | ||
csvRecord.get("commitments") | ||
); | ||
information.add(comp); | ||
} else { | ||
LOG.error("Unable to find a profile for " + emailAddress); | ||
} | ||
} catch(IllegalArgumentException ex) { | ||
throw new BadArgException("Unable to parse the current information"); | ||
} | ||
} | ||
} | ||
|
||
public Information getInformation(UUID memberId) { | ||
// There should only be one entry per member. | ||
return information.stream() | ||
.filter(entry -> entry.memberId().equals(memberId)) | ||
.findFirst() | ||
.orElseThrow(() -> new NotFoundException("Current Information not found for member: " + memberId)); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
server/src/main/java/com/objectcomputing/checkins/services/reports/Feedback.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,28 @@ | ||
package com.objectcomputing.checkins.services.reports; | ||
|
||
import io.micronaut.core.annotation.Introspected; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
import java.time.LocalDate; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
@Introspected | ||
class Feedback { | ||
@AllArgsConstructor | ||
@Getter | ||
public static class Answer { | ||
private final String memberName; | ||
private final LocalDate submitted; | ||
private final String question; | ||
private final String answer; | ||
private final String type; | ||
private final int number; | ||
} | ||
|
||
private String name; | ||
private List<Answer> answers; | ||
} | ||
|
Oops, something went wrong.