Skip to content

Commit 17bf940

Browse files
authored
Merge pull request #17 from cdlib/develop
Second candidate release for phase 1 of knock-off.
2 parents ab0d680 + 52a12d3 commit 17bf940

14 files changed

+802
-73
lines changed

src/main/java/org/cdlib/ill/report/api/CampusILLDataRestController.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.cdlib.ill.report.vdx.VdxLending;
1414
import org.cdlib.ill.report.vdx.VdxBorrowingRepository;
1515
import org.cdlib.ill.report.vdx.VdxLendingRepository;
16+
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingDetail;
17+
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingDetailRepository;
1618
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingBilling;
1719
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingBillingRepository;
1820
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingUnfilledDetail;
@@ -44,7 +46,25 @@ public class CampusILLDataRestController {
4446
private SpVdxLendingUnfilledDetailRepository vdxLendingUnfilledRepo;
4547
@Autowired
4648
private SpVdxLendingBillingRepository vdxLendingBillingRepo;
49+
@Autowired
50+
private SpVdxBorrowingDetailRepository vdxBorrowingDetailRepo;
4751

52+
@RequestMapping(value = "{campusCode}/borrowing_detail.csv", produces = {"text/csv"})
53+
public void getBorrowingDetailCsv(Writer output,
54+
@PathVariable("campusCode") String campusCode,
55+
@RequestParam(required = false, name = "startDate", defaultValue = "1900-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
56+
@RequestParam(required = false, name = "endDate", defaultValue = "2100-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) throws IOException {
57+
CsvMapper mapper = new CsvMapper();
58+
CsvSchema schema = mapper.schemaFor(SpVdxBorrowingDetail.class).withHeader();
59+
List<SpVdxBorrowingDetail> data = vdxBorrowingDetailRepo
60+
.getBorrowingDetail(
61+
VdxCampus.fromCode(campusCode)
62+
.map(VdxCampus::getCode)
63+
.orElse("%"),
64+
startDate, endDate);
65+
mapper.writer(schema).writeValue(output, data);
66+
}
67+
4868
@RequestMapping(value = "{campusCode}/borrowing.xml", produces = {"application/xml"})
4969
public HttpEntity<List<VdxBorrowing>> getCampusBorrowingXml(@PathVariable("campusCode") String campusCode,
5070
@RequestParam(required = false, name = "startDate", defaultValue = "1900-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,

src/main/java/org/cdlib/ill/report/api/CampusILLStatisticsRestController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingSummaryRepository;
3333
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingTat;
3434
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingTatRepository;
35+
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingUnfilledSummary;
36+
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingUnfilledSummaryRepository;
3537
import org.springframework.beans.factory.annotation.Autowired;
3638
import org.springframework.format.annotation.DateTimeFormat;
3739
import org.springframework.web.bind.annotation.PathVariable;
@@ -74,6 +76,8 @@ public class CampusILLStatisticsRestController {
7476
@Autowired
7577
private SpVdxBorrowingUnfilledSummaryRepository spVdxBorrowingUnfilledSummaryRepo;
7678
@Autowired
79+
private SpVdxLendingUnfilledSummaryRepository spVdxLendingUnfilledSummaryRepo;
80+
@Autowired
7781
private SpVdxBorrowingTatRepository spVdxBorrowingTatRepo;
7882
@Autowired
7983
private SpVdxLendingTatRepository spVdxLendingTatRepo;
@@ -187,6 +191,17 @@ public void getVdxBorrowingUnfilled(Writer output,
187191
List<SpVdxBorrowingUnfilledSummary> data = spVdxBorrowingUnfilledSummaryRepo.getBorrowingUnfilledSummary(VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"), startDate, endDate).collect(Collectors.toList());
188192
mapper.writer(schema).writeValue(output, data);
189193
}
194+
195+
@RequestMapping(value = "{campusCode}/lending_unfilled.csv", produces = {"text/csv"})
196+
public void getVdxLendingUnfilled(Writer output,
197+
@PathVariable("campusCode") String campusCode,
198+
@RequestParam(required = false, name = "startDate", defaultValue = "1900-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
199+
@RequestParam(required = false, name = "endDate", defaultValue = "2100-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) throws IOException {
200+
CsvMapper mapper = new CsvMapper();
201+
CsvSchema schema = mapper.schemaFor(SpVdxLendingUnfilledSummary.class).withHeader();
202+
List<SpVdxLendingUnfilledSummary> data = spVdxLendingUnfilledSummaryRepo.getLendingUnfilledSummary(VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"), startDate, endDate).collect(Collectors.toList());
203+
mapper.writer(schema).writeValue(output, data);
204+
}
190205

191206
@RequestMapping(value = "{campusCode}/borrowing_tat.csv", produces = {"text/csv"})
192207
public void getVdxBorrowingTat(Writer output,

src/main/java/org/cdlib/ill/report/excel/XLSXController.java

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingTatRepository;
1717
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingUC;
1818
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingUCRepository;
19+
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingUnfilledSummary;
20+
import org.cdlib.ill.report.vdx.procedures.SpVdxBorrowingUnfilledSummaryRepository;
1921
import org.cdlib.ill.report.vdx.procedures.SpVdxCopyright;
2022
import org.cdlib.ill.report.vdx.procedures.SpVdxCopyrightRepository;
2123
import org.cdlib.ill.report.vdx.procedures.SpVdxJournalBorrowing;
@@ -28,6 +30,8 @@
2830
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingSummaryRepository;
2931
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingTat;
3032
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingTatRepository;
33+
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingUnfilledSummary;
34+
import org.cdlib.ill.report.vdx.procedures.SpVdxLendingUnfilledSummaryRepository;
3135
import org.springframework.beans.factory.annotation.Autowired;
3236
import org.springframework.format.annotation.DateTimeFormat;
3337
import org.springframework.stereotype.Controller;
@@ -66,7 +70,66 @@ public class XLSXController {
6670
private SpVdxCopyrightRepository spVdxCopyrightRepo;
6771
@Autowired
6872
private SpVdxJournalBorrowingRepository spVdxJournalBorrowingRepo;
73+
@Autowired
74+
private SpVdxBorrowingUnfilledSummaryRepository spVdxBorrowingUnfilledSummaryRepo;
75+
@Autowired
76+
private SpVdxLendingUnfilledSummaryRepository spVdxLendingUnfilledSummaryRepo;
6977

78+
@RequestMapping(
79+
value = "{campusCode}/borrowing_unfilled_summary.xlsx",
80+
produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
81+
public void getBorrowingUnfilledSummary(
82+
@PathVariable("campusCode") String campusCode,
83+
OutputStream output,
84+
@RequestParam(required = false, name = "startDate", defaultValue = "1900-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
85+
@RequestParam(required = false, name = "endDate", defaultValue = "2100-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) throws IOException {
86+
ReportWorkbookBuilder.newWorkbook(SpVdxBorrowingUnfilledSummary.class)
87+
.fieldText("Borrowing Campus", summary -> summary.getReqCampus().getCode())
88+
.fieldText("Borrowing Library", summary -> summary.getReqName())
89+
.fieldText("Lending Library", summary -> summary.getRespName())
90+
.fieldText("Service Type", summary -> summary.getServiceTp().getCode())
91+
.fieldNum("Total", summary -> summary.getCount())
92+
.data(spVdxBorrowingUnfilledSummaryRepo.getBorrowingUnfilledSummary(
93+
VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"),
94+
startDate,
95+
endDate).collect(Collectors.toList()))
96+
.pivotRow(0)
97+
.pivotRow(1)
98+
.pivotColumn(3)
99+
.pivotValue(4, DataConsolidateFunction.SUM, "# of Unfilled Requests")
100+
.build()
101+
.write(output);
102+
}
103+
104+
@RequestMapping(
105+
value = "{campusCode}/lending_unfilled_summary.xlsx",
106+
produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
107+
public void getLendingUnfilledSummary(
108+
@PathVariable("campusCode") String campusCode,
109+
OutputStream output,
110+
@RequestParam(required = false, name = "startDate", defaultValue = "1900-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate startDate,
111+
@RequestParam(required = false, name = "endDate", defaultValue = "2100-01-01") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate endDate) throws IOException {
112+
ReportWorkbookBuilder.newWorkbook(SpVdxLendingUnfilledSummary.class)
113+
.fieldText("Lending Campus", summary -> summary.getRespCampus().getCode())
114+
.fieldText("Lending Library", SpVdxLendingUnfilledSummary::getRespName)
115+
.fieldText("Borrowing Library Type", SpVdxLendingUnfilledSummary::getReqLoctype)
116+
.fieldText("Borrowing Library", SpVdxLendingUnfilledSummary::getReqName)
117+
.fieldText("Service Type", summary -> summary.getServiceTp().getCode())
118+
.fieldNum("Total", summary -> summary.getCount())
119+
.data(spVdxLendingUnfilledSummaryRepo.getLendingUnfilledSummary(
120+
VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"),
121+
startDate,
122+
endDate).collect(Collectors.toList()))
123+
.pivotRow(0)
124+
.pivotRow(1)
125+
.pivotRow(2)
126+
.pivotRow(3)
127+
.pivotColumn(4)
128+
.pivotValue(5, DataConsolidateFunction.SUM, "# of Unfilled Responses")
129+
.build()
130+
.write(output);
131+
}
132+
70133
@RequestMapping(
71134
value = "{campusCode}/borrowing_summary.xlsx",
72135
produces = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
@@ -78,7 +141,7 @@ public void getBorrowingSummary(
78141
ReportWorkbookBuilder.newWorkbook(SpVdxBorrowingSummary.class)
79142
.fieldText("Borrowing Campus", summary -> summary.getReqCampus().getCode())
80143
.fieldText("Borrowing Library", summary -> summary.getReqName())
81-
.fieldText("Lender Category", summary -> summary.getRespCategory().getCode())
144+
.fieldText("Lender Category", summary -> summary.getRespCategory().getDescr())
82145
.fieldNum("Total", summary -> summary.getCount())
83146
.data(spVdxBorrowingSummaryRepo.getBorrowingSummary(
84147
VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"),
@@ -103,7 +166,7 @@ public void getLendingSummary(
103166
ReportWorkbookBuilder.newWorkbook(SpVdxLendingSummary.class)
104167
.fieldText("Lending Campus", summary -> summary.getRespCampus().getCode())
105168
.fieldText("Lending Library", summary -> summary.getRespName())
106-
.fieldText("Borrower Category", summary -> summary.getReqCategory().getCode())
169+
.fieldText("Borrower Category", summary -> summary.getReqCategory().getDescr())
107170
.fieldNum("Total", summary -> summary.getCount())
108171
.data(spVdxLendingSummaryRepo.getLendingSummary(
109172
VdxCampus.fromCode(campusCode).map(VdxCampus::getCode).orElse("%"),

src/main/java/org/cdlib/ill/report/vdx/VdxCampus.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
public enum VdxCampus {
66

77
None("", "None"),
8-
UCLADocumentDelivery("OELA", "UCLA Document Delivery"),
98
NorthernRegionalLibraryFacility("NRLF", "Northern Regional Library Facility"),
109
SouthernRegionalLibraryFacility("SRLF", "Southern Regional Library Facility"),
1110
Berkeley("UCB", "UC Berkeley"),
1211
Davis("UCD", "UC Davis"),
1312
Irvine("UCI", "UC Irvine"),
1413
LosAngeles("UCLA", "UC Los Angeles"),
14+
UCLADocumentDelivery("OELA", "UCLA Document Delivery"),
1515
Merced("UCM", "UC Merced"),
1616
Riverside("UCR", "UC Riverside"),
1717
SantaBarbara("UCSB", "UC Santa Barbara"),

src/main/java/org/cdlib/ill/report/vdx/VdxILLCategory.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,26 @@
44

55
public enum VdxILLCategory {
66

7-
UC("U"),
8-
ISOPartners("I"),
9-
OCLC("");
7+
UC("U", "UC"),
8+
ISOPartners("I", "ISO"),
9+
OCLC("", "OCLC");
1010

1111
private final String code;
12+
private final String descr;
1213

13-
private VdxILLCategory(String code) {
14+
private VdxILLCategory(String code, String descr) {
1415
this.code = code;
16+
this.descr = descr;
1517
}
1618

1719
public String getCode() {
1820
return code;
1921
}
2022

23+
public String getDescr() {
24+
return descr;
25+
}
26+
2127
public static Optional<VdxILLCategory> fromCode(String code) {
2228
for (VdxILLCategory category : values()) {
2329
if (category.getCode().equalsIgnoreCase(code)) {

src/main/java/org/cdlib/ill/report/vdx/VdxILLCategorySerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public VdxILLCategorySerializer(Class<VdxILLCategory> t) {
1717

1818
@Override
1919
public void serialize(VdxILLCategory category, JsonGenerator jg, SerializerProvider sp) throws IOException {
20-
jg.writeString(category.getCode());
20+
jg.writeString(category.getDescr());
2121
}
2222

2323
}

0 commit comments

Comments
 (0)