Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
270a611c55
|
@ -26,3 +26,4 @@
|
|||
* Fix commonmark group and bump version (#1500)
|
||||
* Remove dep used for local testing
|
||||
* Bump jackson & logback versions
|
||||
* Fix StringType element properties not being copied in various Address, HumanName convertors
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address10_30 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.getLine().add(String10_30.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_30.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_30.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_30.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address10_30 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.getLine().add(String10_30.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_30.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_30.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_30.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName10_30 {
|
|||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamilyElement(String10_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_30.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName10_30 {
|
|||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_30.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String10_30.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_30.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_30.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address10_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.getLine().add(String10_40.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_40.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address10_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(String10_40.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_40.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName10_40 {
|
|||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamilyElement(String10_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName10_40 {
|
|||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_40.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String10_40.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address10_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getLine()) tgt.getLine().add(String10_50.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_50.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address10_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.getLine().add(String10_50.convertString(t));
|
||||
if (src.hasCityElement()) tgt.setCityElement(String10_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrictElement()) tgt.setDistrictElement(String10_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasStateElement()) tgt.setStateElement(String10_50.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName10_50 {
|
|||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getFamily()) tgt.setFamilyElement(String10_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName10_50 {
|
|||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasTextElement()) tgt.setTextElement(String10_50.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String10_50.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.getGiven().add(String10_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String10_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String10_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period10_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address14_30 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.getLine().add(String14_30.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_30.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_30.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_30.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address14_30 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.getLine().add(String14_30.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_30.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_30.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_30.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName14_30 {
|
|||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_30.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamilyElement(String14_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_30.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_30.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName14_30 {
|
|||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_30.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String14_30.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_30.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_30.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_30.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address14_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.getLine().add(String14_40.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_40.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address14_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(String14_40.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_40.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName14_40 {
|
|||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamilyElement(String14_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName14_40 {
|
|||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_40.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String14_40.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address14_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getLine()) tgt.getLine().add(String14_50.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_50.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address14_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.getLine().add(String14_50.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String14_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String14_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String14_50.convertString(src.getStateElement()));
|
||||
|
|
|
@ -11,10 +11,10 @@ public class HumanName14_50 {
|
|||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamily(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getFamily()) tgt.setFamilyElement(String14_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu2016may.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ public class HumanName14_50 {
|
|||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String14_50.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.addFamily(src.getFamily());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
if (src.hasFamily()) tgt.getFamily().add(String14_50.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.getGiven().add(String14_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String14_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String14_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period14_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address30_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.getLine().add(String30_40.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String30_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String30_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String30_40.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address30_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getLine()) tgt.getLine().add(String30_40.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String30_40.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String30_40.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String30_40.convertString(src.getStateElement()));
|
||||
|
|
|
@ -12,9 +12,9 @@ public class HumanName30_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.setFamilyElement(String30_40.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.getGiven().add(String30_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String30_40.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String30_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ public class HumanName30_40 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_40.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.setFamilyElement(String30_40.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getGiven()) tgt.getGiven().add(String30_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String30_40.convertString(t));
|
||||
for (org.hl7.fhir.r4.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String30_40.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period30_40.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class Address30_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getLine()) tgt.getLine().add(String30_50.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String30_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String30_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String30_50.convertString(src.getStateElement()));
|
||||
|
@ -29,7 +29,7 @@ public class Address30_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertAddressUse(src.getUseElement()));
|
||||
if (src.hasType()) tgt.setTypeElement(convertAddressType(src.getTypeElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_50.convertString(src.getTextElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.addLine(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getLine()) tgt.getLine().add(String30_50.convertString(t));
|
||||
if (src.hasCity()) tgt.setCityElement(String30_50.convertString(src.getCityElement()));
|
||||
if (src.hasDistrict()) tgt.setDistrictElement(String30_50.convertString(src.getDistrictElement()));
|
||||
if (src.hasState()) tgt.setStateElement(String30_50.convertString(src.getStateElement()));
|
||||
|
|
|
@ -12,9 +12,9 @@ public class HumanName30_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_50.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.setFamilyElement(String30_50.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getGiven()) tgt.getGiven().add(String30_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String30_50.convertString(t));
|
||||
for (org.hl7.fhir.dstu3.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String30_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
@ -26,9 +26,9 @@ public class HumanName30_50 {
|
|||
if (src.hasUse()) tgt.setUseElement(convertNameUse(src.getUseElement()));
|
||||
if (src.hasText()) tgt.setTextElement(String30_50.convertString(src.getTextElement()));
|
||||
if (src.hasFamily()) tgt.setFamilyElement(String30_50.convertString(src.getFamilyElement()));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.addGiven(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.addPrefix(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.addSuffix(t.getValue());
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getGiven()) tgt.getGiven().add(String30_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getPrefix()) tgt.getPrefix().add(String30_50.convertString(t));
|
||||
for (org.hl7.fhir.r5.model.StringType t : src.getSuffix()) tgt.getSuffix().add(String30_50.convertString(t));
|
||||
if (src.hasPeriod()) tgt.setPeriod(Period30_50.convertPeriod(src.getPeriod()));
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package org.hl7.fhir.utilities.npm;
|
||||
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class FilesystemPackageCacheLock {
|
||||
|
||||
private static final ConcurrentHashMap<File, ReadWriteLock> locks = new ConcurrentHashMap<>();
|
||||
|
||||
private final File lockFile;
|
||||
|
||||
public FilesystemPackageCacheLock(File cacheFolder, String name) throws IOException {
|
||||
this.lockFile = new File(cacheFolder, name + ".lock");
|
||||
if (!lockFile.isFile()) {
|
||||
TextFile.stringToFile("", lockFile);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T doWriteWithLock(FilesystemPackageCacheManager.CacheLockFunction<T> f) throws IOException {
|
||||
|
||||
try (FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel()) {
|
||||
locks.putIfAbsent(lockFile, new ReentrantReadWriteLock());
|
||||
ReadWriteLock lock = locks.get(lockFile);
|
||||
lock.writeLock().lock();
|
||||
final FileLock fileLock = channel.lock();
|
||||
T result = null;
|
||||
try {
|
||||
result = f.get();
|
||||
} finally {
|
||||
fileLock.release();
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
if (!lockFile.delete()) {
|
||||
lockFile.deleteOnExit();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,12 +3,8 @@ package org.hl7.fhir.utilities.npm;
|
|||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.FileLock;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -118,8 +114,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
private JsonArray buildInfo;
|
||||
private boolean suppressErrors;
|
||||
private boolean minimalMemory;
|
||||
|
||||
|
||||
|
||||
public FilesystemPackageCacheManager(boolean userMode) throws IOException {
|
||||
init(userMode ? FilesystemPackageCacheMode.USER : FilesystemPackageCacheMode.SYSTEM);
|
||||
}
|
||||
|
@ -139,36 +134,35 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
init(FilesystemPackageCacheMode.CUSTOM);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void init(FilesystemPackageCacheMode mode) throws IOException {
|
||||
initPackageServers();
|
||||
|
||||
switch (mode) {
|
||||
case SYSTEM:
|
||||
if (Utilities.isWindows()) {
|
||||
cacheFolder = new File(Utilities.path(System.getenv("ProgramData"), ".fhir", "packages"));
|
||||
} else {
|
||||
cacheFolder = new File(Utilities.path("/var", "lib", ".fhir", "packages"));
|
||||
}
|
||||
break;
|
||||
case USER:
|
||||
cacheFolder = new File(Utilities.path(System.getProperty("user.home"), ".fhir", "packages"));
|
||||
break;
|
||||
case TESTING:
|
||||
cacheFolder = new File(Utilities.path("[tmp]", ".fhir", "packages"));
|
||||
break;
|
||||
case CUSTOM:
|
||||
if (!cacheFolder.exists()) {
|
||||
if (mode == FilesystemPackageCacheMode.CUSTOM) {
|
||||
if (!this.cacheFolder.exists()) {
|
||||
throw new FHIRException("The folder ''"+cacheFolder+"' could not be found");
|
||||
}
|
||||
default:
|
||||
break;
|
||||
} else {
|
||||
this.cacheFolder = getCacheFolder(mode);
|
||||
}
|
||||
|
||||
initCacheFolder();
|
||||
}
|
||||
|
||||
public static File getCacheFolder(FilesystemPackageCacheMode mode) throws IOException {
|
||||
switch (mode) {
|
||||
case SYSTEM:
|
||||
if (Utilities.isWindows()) {
|
||||
return new File(Utilities.path(System.getenv("ProgramData"), ".fhir", "packages"));
|
||||
} else {
|
||||
return new File(Utilities.path("/var", "lib", ".fhir", "packages"));
|
||||
}
|
||||
case USER:
|
||||
return new File(Utilities.path(System.getProperty("user.home"), ".fhir", "packages"));
|
||||
case TESTING:
|
||||
return new File(Utilities.path("[tmp]", ".fhir", "packages"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void initCacheFolder() throws IOException {
|
||||
if (!(cacheFolder.exists()))
|
||||
Utilities.createDirectory(cacheFolder.getAbsolutePath());
|
||||
|
@ -254,7 +248,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
private void clearCache() throws IOException {
|
||||
for (File f : cacheFolder.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
new CacheLock(f.getName()).doWithLock(() -> {
|
||||
new FilesystemPackageCacheLock(cacheFolder, f.getName()).doWriteWithLock(() -> {
|
||||
Utilities.clearDirectory(f.getAbsolutePath());
|
||||
try {
|
||||
FileUtils.deleteDirectory(f);
|
||||
|
@ -399,7 +393,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
* @throws IOException
|
||||
*/
|
||||
public void removePackage(String id, String ver) throws IOException {
|
||||
new CacheLock(id + "#" + ver).doWithLock(() -> {
|
||||
new FilesystemPackageCacheLock(cacheFolder, id + "#" + ver).doWriteWithLock(() -> {
|
||||
String f = Utilities.path(cacheFolder, id + "#" + ver);
|
||||
File ff = new File(f);
|
||||
if (ff.exists()) {
|
||||
|
@ -490,7 +484,7 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
}
|
||||
|
||||
String v = version;
|
||||
return new CacheLock(id + "#" + version).doWithLock(() -> {
|
||||
return new FilesystemPackageCacheLock(cacheFolder, id + "#" + version).doWriteWithLock(() -> {
|
||||
NpmPackage pck = null;
|
||||
String packRoot = Utilities.path(cacheFolder, id + "#" + v);
|
||||
try {
|
||||
|
@ -1015,34 +1009,6 @@ public class FilesystemPackageCacheManager extends BasePackageCacheManager imple
|
|||
}
|
||||
}
|
||||
|
||||
public class CacheLock {
|
||||
|
||||
private final File lockFile;
|
||||
|
||||
public CacheLock(String name) throws IOException {
|
||||
this.lockFile = new File(cacheFolder, name + ".lock");
|
||||
if (!lockFile.isFile()) {
|
||||
TextFile.stringToFile("", lockFile);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T doWithLock(CacheLockFunction<T> f) throws FileNotFoundException, IOException {
|
||||
try (FileChannel channel = new RandomAccessFile(lockFile, "rw").getChannel()) {
|
||||
final FileLock fileLock = channel.lock();
|
||||
T result = null;
|
||||
try {
|
||||
result = f.get();
|
||||
} finally {
|
||||
fileLock.release();
|
||||
}
|
||||
if (!lockFile.delete()) {
|
||||
lockFile.deleteOnExit();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean packageExists(String id, String ver) throws IOException {
|
||||
if (packageInstalled(id, ver)) {
|
||||
return true;
|
||||
|
|
|
@ -4,7 +4,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -100,4 +103,37 @@ public class FilesystemPackageManagerTests {
|
|||
};
|
||||
assertEquals( System.getenv("ProgramData") + "\\.fhir\\packages", filesystemPackageCacheManager.getFolder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multithreadingTest() throws IOException {
|
||||
String pcmPath = Files.createTempDirectory("fpcm-multithreadingTest").toFile().getAbsolutePath();
|
||||
FilesystemPackageCacheManager pcm = new FilesystemPackageCacheManager(pcmPath);
|
||||
|
||||
final AtomicInteger totalSuccessful = new AtomicInteger();
|
||||
|
||||
List<Thread> threads = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final int index = i;
|
||||
Thread t = new Thread(() -> {
|
||||
try {
|
||||
pcm.loadPackage("hl7.fhir.xver-extensions#0.0.12");
|
||||
totalSuccessful.incrementAndGet();
|
||||
System.out.println("Thread " + index + " completed");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println("Thread " + index + " failed");
|
||||
}
|
||||
});
|
||||
t.start();
|
||||
threads.add(t);
|
||||
}
|
||||
threads.forEach(t -> {
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
}
|
||||
});
|
||||
assertEquals(3, totalSuccessful.get());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue