private void migrateValue(BaseObject parentalObject, BaseObject obstetricObject, Integer propValue, String propName) { parentalObject.removeField(OLD_PREFIX + propName); if (propValue != null) { obstetricObject.setIntValue(propName, propValue); } } }
/** * Remove deprecated fields (properties deleted from the XClass) from an object. * * @param object the object to synchronize * @param context the current request context */ private void synchronizeObject(BaseObject object, XWikiContext context) { for (BaseProperty property : object.getXClass(context).getDeprecatedObjectProperties(object)) { object.removeField(property.getName()); } } }
private void migrateSolvedGenes(XWikiDocument doc, XWikiContext context, List<String> geneList) throws HibernateException, XWikiException { BaseObject patient = doc.getXObject(this.patientClassReference); StringProperty oldTarget = (StringProperty) patient.get(SOLVED_NAME); if (oldTarget == null) { return; } patient.removeField(SOLVED_NAME); String geneName = oldTarget.getValue(); if (!StringUtils.isBlank(geneName)) { BaseObject gene = doc.newXObject(this.geneClassReference, context); gene.setStringValue(GENE_NAME, geneName); gene.setStringValue(STATUS_NAME, "solved"); geneList.add(geneName); } }
private void migrateSolvedGenes(XWikiDocument doc, XWikiContext context, List<String> geneList) throws HibernateException, XWikiException { BaseObject patient = doc.getXObject(this.patientClassReference); StringProperty oldTarget = (StringProperty) patient.get(SOLVED_NAME); if (oldTarget == null) { return; } patient.removeField(SOLVED_NAME); String geneName = oldTarget.getValue(); if (!StringUtils.isBlank(geneName)) { BaseObject gene = doc.newXObject(this.geneClassReference, context); gene.setStringValue(GENE_NAME, geneName); gene.setStringValue(STATUS_NAME, "solved"); geneList.add(geneName); } }
} else if ("birth".equals(measurement.getStringValue("type"))) { measurement.setFloatValue(AGE_PROPERTY_NAME, 0); measurement.removeField(DATE_PROPERTY_NAME); continue; measurement.removeField(AGE_PROPERTY_NAME); } else { measurement.setFloatValue(AGE_PROPERTY_NAME,
} else if ("birth".equals(measurement.getStringValue("type"))) { measurement.setFloatValue(AGE_PROPERTY_NAME, 0); measurement.removeField(DATE_PROPERTY_NAME); continue; measurement.removeField(AGE_PROPERTY_NAME); } else { measurement.setFloatValue(AGE_PROPERTY_NAME,
/** * @since 2.2M2 */ public void renameProperties(DocumentReference classReference, Map<String, String> fieldsToRename) { List<BaseObject> objects = getXObjects(classReference); if (objects == null) { return; } for (BaseObject bobject : objects) { if (bobject == null) { continue; } for (Map.Entry<String, String> entry : fieldsToRename.entrySet()) { String origname = entry.getKey(); String newname = entry.getValue(); BaseProperty origprop = (BaseProperty) bobject.safeget(origname); if (origprop != null) { BaseProperty prop = (BaseProperty) origprop.clone(); bobject.removeField(origname); prop.setName(newname); bobject.addField(newname, prop); } } } setContentDirty(true); }
/** * For each {@code genesymbol} field, rename it to {@code gene} and swtich the value from HGNC symbol to Ensembl ID, * if provided. * * @param doc XWiki document * @param geneVariantClassReference reference to {@code GeneVariantClass} * @throws XWikiException if property value cannot be set */ private void migrateGeneVariants(final XWikiDocument doc, final DocumentReference geneVariantClassReference) throws XWikiException { final List<BaseObject> variants = doc.getXObjects(geneVariantClassReference); if (variants == null) { return; } for (final BaseObject variant : variants) { final StringProperty oldGeneName = setPropertyValue(variant, OLD_GENE_NAME); // Rename all "genesymbol" properties to "gene". if (oldGeneName != null) { variant.removeField(OLD_GENE_NAME); final StringProperty newGeneName = (StringProperty) oldGeneName.clone(); newGeneName.setName(GENE_NAME); variant.addField(GENE_NAME, newGeneName); } } }
/** * For each {@code genesymbol} field, rename it to {@code gene} and swtich the value from HGNC symbol to Ensembl ID, * if provided. * * @param doc XWiki document * @param geneVariantClassReference reference to {@code GeneVariantClass} * @throws XWikiException if property value cannot be set */ private void migrateGeneVariants(final XWikiDocument doc, final DocumentReference geneVariantClassReference) throws XWikiException { final List<BaseObject> variants = doc.getXObjects(geneVariantClassReference); if (variants == null) { return; } for (final BaseObject variant : variants) { final StringProperty oldGeneName = setPropertyValue(variant, OLD_GENE_NAME); // Rename all "genesymbol" properties to "gene". if (oldGeneName != null) { variant.removeField(OLD_GENE_NAME); final StringProperty newGeneName = (StringProperty) oldGeneName.clone(); newGeneName.setName(GENE_NAME); variant.addField(GENE_NAME, newGeneName); } } }
} else if ("birth".equals(measurement.getStringValue("type"))) { measurement.setIntValue(AGE_PROPERTY_NAME, 0); measurement.removeField(DATE_PROPERTY_NAME); continue; measurement.removeField(AGE_PROPERTY_NAME); } else { int age = Months.monthsBetween(new DateTime(birthDate), new DateTime(measurementDate)).getMonths();
patient.removeField(OLD_TYPE_NAME); patient.removeField(TARGET_RELATIVE_NAME); BaseObject relative = doc.newXObject(relativeClassReference, context); if ("Mother".equals(oldType.getValue()) || "Father".equals(oldType.getValue())) {
patient.removeField(OLD_TYPE_NAME); patient.removeField(TARGET_RELATIVE_NAME); BaseObject relative = doc.newXObject(relativeClassReference, context); if ("Mother".equals(oldType.getValue()) || "Father".equals(oldType.getValue())) {
continue; object.removeField(this.oldName); LargeStringProperty newProperty = (LargeStringProperty) oldProperty.clone(); newProperty.setName(this.newName);
continue; object.removeField(OLD_NAME); StringProperty newProperty = (StringProperty) oldProperty.clone(); newProperty.setName(NEW_NAME);
continue; object.removeField(OLD_NAME); StringProperty newProperty = (StringProperty) oldProperty.clone(); newProperty.setName(NEW_NAME);
continue; object.removeField(OLD_NAME); StringProperty newProperty = (StringProperty) oldProperty.clone(); newProperty.setName(NEW_NAME);
continue; object.removeField(OLD_NAME); NumberProperty newProperty = oldProperty.clone(); newProperty.setName(NEW_NAME);
continue; object.removeField(OLD_NAME); StringProperty newProperty = (StringProperty) oldProperty.clone(); newProperty.setName(NEW_NAME);
continue; object.removeField(OLD_NAME); NumberProperty newProperty = oldProperty.clone(); newProperty.setName(NEW_NAME);
newObject.removeField(hc.getName()); newObject.setFieldsToRemove(Collections.emptyList()); newObject.safeput("hc", hc);