/** * @param obj the translation object * @return the {@link Scope} stored in the object, null not assigned or unknown */ private Scope getScope(BaseObject obj) { if (obj != null) { StringProperty scopeProperty = (StringProperty) obj.getField(TranslationDocumentModel.TRANSLATIONCLASS_PROP_SCOPE); if (scopeProperty != null) { String scopeString = scopeProperty.getValue(); return EnumUtils.getEnum(Scope.class, scopeString.toUpperCase()); } } return null; }
@Override public BaseProperty newProperty() { return new StringProperty(); }
public Object doInHibernate(Session session) throws HibernateException { Query q = session.createQuery("select s from BaseObject o, StringProperty s where o.className like 'XWiki.XWiki%Rights' and o.id=s.id and (s.name='users' or s.name='groups')"); List lst = q.list(); if (lst.size()==0) return null; List lst2 = new ArrayList(lst.size()); for (Iterator it=lst.iterator(); it.hasNext(); ) { StringProperty sp = (StringProperty) it.next(); LargeStringProperty lsp = new LargeStringProperty(); lsp.setId(sp.getId()); lsp.setName(sp.getName()); lsp.setValue(sp.getValue()); lst2.add(lsp); } for (Iterator it=lst.iterator(); it.hasNext(); ) session.delete(it.next()); for (Iterator it=lst2.iterator(); it.hasNext(); ) session.save(it.next()); return null; } });
private boolean fixValue(StringProperty property) { if (property == null) { return false; } boolean modified = false; String value = property.getValue(); if (this.translations.containsKey(value)) { R54690PhenoTips1195DataMigration.this.logger.debug( "Replacing {} with {}", value, this.translations.get(value)); property.setValue(this.translations.get(value)); modified = true; } return modified; } }
StringProperty property2 = new StringProperty(); property2.setObject(object); property2.setName(name); loadXWikiProperty(property2, context, false); property.setValue(property2.getValue());
StringProperty newProperty = new StringProperty(); newProperty.setName(DATA_NAME); newProperty.setValue(getLifeStatus(data)); data.addField(DATA_NAME, newProperty);
/** * 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); } } }
@Override public BaseProperty newPropertyfromXML(Element ppcel) { if (!isMultiSelect()) { return super.newPropertyfromXML(ppcel); } @SuppressWarnings("unchecked") List<Element> elist = ppcel.elements("value"); BaseProperty lprop = newProperty(); if (lprop instanceof ListProperty) { List<String> llist = ((ListProperty) lprop).getList(); for (int i = 0; i < elist.size(); i++) { Element el = elist.get(i); llist.add(el.getText()); } } else { for (int i = 0; i < elist.size(); i++) { Element el = elist.get(i); ((StringProperty) lprop).setValue(el.getText()); } } return lprop; }
private boolean fixValue(StringProperty property) { if (property == null) { return false; } boolean modified = false; String value = property.getValue(); if (this.translations.containsKey(value)) { R54690PhenoTips1195DataMigration.this.logger.debug( "Replacing {} with {}", value, this.translations.get(value)); property.setValue(this.translations.get(value)); modified = true; } return modified; } }
StringProperty newProperty = new StringProperty(); newProperty.setName(DATA_NAME); newProperty.setValue(getLifeStatus(data)); data.addField(DATA_NAME, newProperty);
/** * 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); } } }
/** * Find the XObject that contains metadata for this feature, if any. * * @param doc the patient's XDocument, where metadata objects are stored * @return the found object, or {@code null} if one wasn't found * @throws XWikiException if accessing the data fails */ private BaseObject findMetadataObject(XWikiDocument doc) throws XWikiException { List<BaseObject> objects = doc.getXObjects(FeatureMetadatum.CLASS_REFERENCE); if (objects != null && !objects.isEmpty()) { for (BaseObject o : objects) { if (o == null) { continue; } StringProperty nameProperty = (StringProperty) o.get(META_PROPERTY_NAME); StringProperty valueProperty = (StringProperty) o.get(META_PROPERTY_VALUE); if (nameProperty != null && StringUtils.equals(nameProperty.getValue(), this.propertyName) && valueProperty != null && StringUtils.equals(valueProperty.getValue(), this.getValue())) { return o; } } } return null; }
@Override public BaseProperty newProperty() { BaseProperty property = new StringProperty(); property.setName(getName()); return property; }
/** * Find the XObject that contains metadata for this feature, if any. * * @param doc the patient's XDocument, where metadata objects are stored * @return the found object, or {@code null} if one wasn't found * @throws XWikiException if accessing the data fails */ private BaseObject findMetadataObject(XWikiDocument doc) throws XWikiException { List<BaseObject> objects = doc.getXObjects(FeatureMetadatum.CLASS_REFERENCE); if (objects != null && !objects.isEmpty()) { for (BaseObject o : objects) { if (o == null) { continue; } StringProperty nameProperty = (StringProperty) o.get(META_PROPERTY_NAME); StringProperty valueProperty = (StringProperty) o.get(META_PROPERTY_VALUE); if (nameProperty != null && StringUtils.equals(nameProperty.getValue(), this.propertyName) && valueProperty != null && StringUtils.equals(valueProperty.getValue(), this.getValue())) { return o; } } } return null; }