improve xls output
This commit is contained in:
parent
50c88dc1c1
commit
be84bb427c
|
@ -3424,16 +3424,17 @@ public class ProfileUtilities extends TranslatingUtilities {
|
|||
}
|
||||
|
||||
// generate an Excel representation of the structure definition
|
||||
public void generateXlsx(OutputStream dest, StructureDefinition structure, boolean asXml) throws IOException, DefinitionException, Exception {
|
||||
public void generateXlsx(OutputStream dest, StructureDefinition structure, boolean asXml, boolean hideMustSupportFalse) throws IOException, DefinitionException, Exception {
|
||||
if (!structure.hasSnapshot())
|
||||
throw new DefinitionException("needs a snapshot");
|
||||
|
||||
XLSXWriter xlsx = new XLSXWriter(dest, structure, asXml);
|
||||
XLSXWriter xlsx = new XLSXWriter(dest, structure, asXml, hideMustSupportFalse);
|
||||
|
||||
for (ElementDefinition child : structure.getSnapshot().getElement()) {
|
||||
xlsx.processElement(child);
|
||||
}
|
||||
xlsx.dump();
|
||||
xlsx.close();
|
||||
}
|
||||
|
||||
private class Slicer extends ElementDefinitionSlicingComponent {
|
||||
|
|
|
@ -58836,7 +58836,7 @@ public class JsonParser extends JsonParserBase {
|
|||
else if (type instanceof ParameterDefinition)
|
||||
composeParameterDefinitionInner((ParameterDefinition) type);
|
||||
else
|
||||
throw new Error("Unhandled type");
|
||||
throw new Error("Unhandled type: "+type.fhirType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,8 +53,10 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.CanonicalType;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.AggregationMode;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionMappingComponent;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionSlicingDiscriminatorComponent;
|
||||
|
@ -65,6 +67,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
|
|||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionMappingComponent;
|
||||
import org.hl7.fhir.r5.model.Type;
|
||||
import org.hl7.fhir.r5.model.UriType;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TextStreamWriter;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCustomFilter;
|
||||
|
@ -84,6 +87,7 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
private XmlParser xml = new XmlParser();
|
||||
private JsonParser json = new JsonParser();
|
||||
private boolean asXml;
|
||||
private boolean hideMustSupportFalse;
|
||||
|
||||
private static String[] titles = {
|
||||
"Path", "Slice Name", "Alias(s)", "Label", "Min", "Max", "Must Support?", "Is Modifier?", "Is Summary?", "Type(s)", "Short",
|
||||
|
@ -92,11 +96,12 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
"Slicing Discriminator", "Slicing Description", "Slicing Ordered", "Slicing Rules", "Base Path", "Base Min", "Base Max",
|
||||
"Condition(s)", "Constraint(s)"};
|
||||
|
||||
public XLSXWriter(OutputStream out, StructureDefinition def, boolean asXml) throws UnsupportedEncodingException {
|
||||
public XLSXWriter(OutputStream out, StructureDefinition def, boolean asXml, boolean hideMustSupportFalse) throws UnsupportedEncodingException {
|
||||
super(out);
|
||||
outStream = out;
|
||||
this.asXml = asXml;
|
||||
this.def = def;
|
||||
this.hideMustSupportFalse = hideMustSupportFalse;
|
||||
sheet = wb.createSheet("Elements");
|
||||
styles = createStyles(wb);
|
||||
Row headerRow = sheet.createRow(0);
|
||||
|
@ -155,7 +160,7 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
|
||||
private static CellStyle createBorderedStyle(Workbook wb){
|
||||
BorderStyle thin = BorderStyle.THIN;
|
||||
short black = IndexedColors.BLACK.getIndex();
|
||||
short black = IndexedColors.GREY_50_PERCENT.getIndex();
|
||||
|
||||
CellStyle style = wb.createCellStyle();
|
||||
style.setBorderRight(thin);
|
||||
|
@ -262,7 +267,17 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
val = o.toString();
|
||||
} else if (o instanceof TypeRefComponent) {
|
||||
TypeRefComponent t = (TypeRefComponent)o;
|
||||
val = t.getCode() + (t.getProfile() == null ? "" : " {" + t.getProfile() + "}") +(t.getTargetProfile() == null ? "" : " {" + t.getTargetProfile() + "}") + (t.getAggregation() == null || t.getAggregation().isEmpty() ? "" : " (" + itemList(t.getAggregation()) + ")");
|
||||
val = t.getCode();
|
||||
if (val == null)
|
||||
val = "";
|
||||
if (val.startsWith("http://hl7.org/fhir/StructureDefinition/"))
|
||||
val = val.substring(40);
|
||||
if (t.hasTargetProfile())
|
||||
val = val+ "(" + canonicalList(t.getTargetProfile()) + ")";
|
||||
if (t.hasProfile())
|
||||
val = val + " {" + canonicalList(t.getProfile()) + "}";
|
||||
if (t.hasAggregation())
|
||||
val = val + " <<" + aggList(t.getAggregation()) + ">>";
|
||||
} else if (o instanceof Coding) {
|
||||
Coding t = (Coding)o;
|
||||
val = (t.getSystem()==null ? "" : t.getSystem()) + (t.getCode()==null ? "" : "#" + t.getCode()) + (t.getDisplay()==null ? "" : " (" + t.getDisplay() + ")");
|
||||
|
@ -285,7 +300,30 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
return s.toString();
|
||||
}
|
||||
|
||||
private String aggList(List<org.hl7.fhir.r5.model.Enumeration<AggregationMode>> list) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
for (org.hl7.fhir.r5.model.Enumeration<AggregationMode> c : list)
|
||||
b.append(c.getValue().toCode());
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private String canonicalList(List<CanonicalType> list) {
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder("|");
|
||||
for (CanonicalType c : list) {
|
||||
String v = c.getValue();
|
||||
if (v.startsWith("http://hl7.org/fhir/StructureDefinition/"))
|
||||
v = v.substring(40);
|
||||
b.append(v);
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
private String renderType(Type value) throws Exception {
|
||||
if (value == null)
|
||||
return "";
|
||||
if (value.isPrimitive())
|
||||
return value.primitiveValue();
|
||||
|
||||
String s = null;
|
||||
ByteArrayOutputStream bs = new ByteArrayOutputStream();
|
||||
if (asXml) {
|
||||
|
@ -338,46 +376,49 @@ public class XLSXWriter extends TextStreamWriter {
|
|||
// sheet.setColumnHidden(i, true);
|
||||
}
|
||||
sheet.createFreezePane(2,1);
|
||||
|
||||
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
|
||||
String address = "A2:AI" + Math.max(Integer.valueOf(sheet.getLastRowNum()), 2);
|
||||
CellRangeAddress[] regions = {
|
||||
CellRangeAddress.valueOf(address)
|
||||
};
|
||||
|
||||
ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("$G2<>\"Y\"");
|
||||
PatternFormatting fill1 = rule1.createPatternFormatting();
|
||||
fill1.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.index);
|
||||
fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
|
||||
if (hideMustSupportFalse) {
|
||||
SheetConditionalFormatting sheetCF = sheet.getSheetConditionalFormatting();
|
||||
String address = "A2:AI" + Math.max(Integer.valueOf(sheet.getLastRowNum()), 2);
|
||||
CellRangeAddress[] regions = {
|
||||
CellRangeAddress.valueOf(address)
|
||||
};
|
||||
|
||||
ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("$Q2<>\"\"");
|
||||
FontFormatting font = rule2.createFontFormatting();
|
||||
font.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
|
||||
font.setFontStyle(true, false);
|
||||
ConditionalFormattingRule rule1 = sheetCF.createConditionalFormattingRule("$G2<>\"Y\"");
|
||||
PatternFormatting fill1 = rule1.createPatternFormatting();
|
||||
fill1.setFillBackgroundColor(IndexedColors.GREY_25_PERCENT.index);
|
||||
fill1.setFillPattern(PatternFormatting.SOLID_FOREGROUND);
|
||||
|
||||
sheetCF.addConditionalFormatting(regions, rule1, rule2);
|
||||
ConditionalFormattingRule rule2 = sheetCF.createConditionalFormattingRule("$Q2<>\"\"");
|
||||
FontFormatting font = rule2.createFontFormatting();
|
||||
font.setFontColorIndex(IndexedColors.GREY_25_PERCENT.index);
|
||||
font.setFontStyle(true, false);
|
||||
|
||||
sheet.setAutoFilter(new CellRangeAddress(0,sheet.getLastRowNum(), 0, titles.length+def.getMapping().size() - 1));
|
||||
|
||||
XSSFSheet xSheet = (XSSFSheet)sheet;
|
||||
sheetCF.addConditionalFormatting(regions, rule1, rule2);
|
||||
|
||||
CTAutoFilter sheetFilter = xSheet.getCTWorksheet().getAutoFilter();
|
||||
CTFilterColumn filterColumn1 = sheetFilter.addNewFilterColumn();
|
||||
filterColumn1.setColId(6);
|
||||
CTCustomFilters filters = filterColumn1.addNewCustomFilters();
|
||||
CTCustomFilter filter1 = filters.addNewCustomFilter();
|
||||
filter1.setOperator(STFilterOperator.NOT_EQUAL);
|
||||
filter1.setVal(" ");
|
||||
|
||||
CTFilterColumn filterColumn2 = sheetFilter.addNewFilterColumn();
|
||||
filterColumn2.setColId(26);
|
||||
CTFilters filters2 = filterColumn2.addNewFilters();
|
||||
filters2.setBlank(true);
|
||||
sheet.setAutoFilter(new CellRangeAddress(0,sheet.getLastRowNum(), 0, titles.length+def.getMapping().size() - 1));
|
||||
|
||||
// We have to apply the filter ourselves by hiding the rows:
|
||||
for (Row row : sheet) {
|
||||
if (row.getRowNum()>0 && (!row.getCell(6).getStringCellValue().equals("Y") || !row.getCell(26).getStringCellValue().isEmpty())) {
|
||||
((XSSFRow) row).getCTRow().setHidden(true);
|
||||
|
||||
XSSFSheet xSheet = (XSSFSheet)sheet;
|
||||
|
||||
CTAutoFilter sheetFilter = xSheet.getCTWorksheet().getAutoFilter();
|
||||
CTFilterColumn filterColumn1 = sheetFilter.addNewFilterColumn();
|
||||
filterColumn1.setColId(6);
|
||||
CTCustomFilters filters = filterColumn1.addNewCustomFilters();
|
||||
CTCustomFilter filter1 = filters.addNewCustomFilter();
|
||||
filter1.setOperator(STFilterOperator.NOT_EQUAL);
|
||||
filter1.setVal(" ");
|
||||
|
||||
CTFilterColumn filterColumn2 = sheetFilter.addNewFilterColumn();
|
||||
filterColumn2.setColId(26);
|
||||
CTFilters filters2 = filterColumn2.addNewFilters();
|
||||
filters2.setBlank(true);
|
||||
|
||||
// We have to apply the filter ourselves by hiding the rows:
|
||||
for (Row row : sheet) {
|
||||
if (row.getRowNum()>0 && (!row.getCell(6).getStringCellValue().equals("Y") || !row.getCell(26).getStringCellValue().isEmpty())) {
|
||||
((XSSFRow) row).getCTRow().setHidden(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
sheet.setActiveCell(new CellAddress(sheet.getRow(1).getCell(0)));
|
||||
|
|
20
release.bat
20
release.bat
|
@ -1,21 +1,23 @@
|
|||
REM replace versions before running
|
||||
REM make sure you are committed
|
||||
|
||||
@echo off
|
||||
echo
|
||||
|
||||
echo ===============================================================
|
||||
echo upgrade and release fhir.core from 3.7.33-SNAPSHOT to 3.7.34-SNAPSHOT
|
||||
echo ===============================================================
|
||||
echo =====================================================================
|
||||
echo upgrade and release fhir.core from 3.7.34-SNAPSHOT to 3.7.35-SNAPSHOT
|
||||
echo =====================================================================
|
||||
echo
|
||||
echo check versions and make sure committed...
|
||||
pause
|
||||
|
||||
call mvn versions:set -DnewVersion=3.7.34-SNAPSHOT
|
||||
call mvn versions:set -DnewVersion=3.7.35-SNAPSHOT
|
||||
call git commit -a -m "Release new version"
|
||||
call git push origin master
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.java" --includeSubDirectories --find "3.7.33-SNAPSHOT" --replace "3.7.34-SNAPSHOT"
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\fhir-ig-publisher" --fileMask "*.xml" --includeSubDirectories --find "3.7.33-SNAPSHOT" --replace "3.7.34-SNAPSHOT"
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.xml" --find "3.7.33-SNAPSHOT" --replace "3.7.34-SNAPSHOT"
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.java" --includeSubDirectories --find "3.7.34-SNAPSHOT" --replace "3.7.35-SNAPSHOT"
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\fhir-ig-publisher" --fileMask "*.xml" --includeSubDirectories --find "3.7.34-SNAPSHOT" --replace "3.7.35-SNAPSHOT"
|
||||
call "C:\tools\fnr.exe" --cl --dir "C:\work\org.hl7.fhir\build" --fileMask "*.xml" --find "3.7.34-SNAPSHOT" --replace "3.7.35-SNAPSHOT"
|
||||
call mvn deploy
|
||||
call python c:\tools\zulip-api\zulip\zulip\send.py --stream committers/notification --subject "java core" -m "New Java Core v3.7.34-SNAPSHOT released." --config-file zuliprc
|
||||
call python c:\tools\zulip-api\zulip\zulip\send.py --stream committers/notification --subject "java core" -m "New Java Core v3.7.35-SNAPSHOT released." --config-file zuliprc
|
||||
|
||||
echo ===============================================================
|
||||
echo all done
|
||||
|
|
Loading…
Reference in New Issue