/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseProperty#toText() */ @Override public String toText() { String value = getValue(); if (value != null) { return value; } return ""; }
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseProperty#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { // Same Java object, they sure are equal if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if ((getValue() == null) && (((BaseStringProperty) obj).getValue() == null)) { return true; } return getValue().equals(((BaseStringProperty) obj).getValue()); }
/** * Extract a list of users or groups from an XProperty, and append the outcome to a specified set. * * @param xproperty the XWiki property from which to get the values; may be {@code null} * @param target the container where to add the extracted users/groups */ private void extractReferences(BaseStringProperty xproperty, Collection<String> target) { if (xproperty != null) { String[] references = xproperty.getValue().split(COMMA); for (String reference : references) { if (StringUtils.isNotBlank(reference)) { target.add(reference); } } } }
@Override public String getValue() { String value = super.getValue(); if (isEncrypted(value)) { return decrypt(value); } return value; }
@Override public String getValue() { String value = super.getValue(); if (isEncrypted(value)) { return decrypt(value); } return value; }
/** * {@inheritDoc} * * @see com.xpn.xwiki.objects.BaseProperty#clone() */ @Override public Object clone() { BaseStringProperty property = (BaseStringProperty) super.clone(); property.setValue(getValue()); return property; } }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } }
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; Map<String, EntityReference> refs = new LinkedHashMap<>(); refs.put(GENE_KEY, GENE_CLASS_REFERENCE); refs.put(VARIANT_KEY, VARIANT_CLASS_REFERENCE); for (String key : refs.keySet()) { List<BaseObject> xWikiObjects = doc.getXObjects(refs.get(key)); if (xWikiObjects == null || xWikiObjects.isEmpty()) { continue; } for (BaseObject object : xWikiObjects) { if (object == null) { continue; } BaseStringProperty field = (BaseStringProperty) object.getField(key); if (field == null || StringUtils.isEmpty(field.getValue())) { doc.removeXObject(object); } } } } }
private String getFieldValue(BaseObject variantObject, String property) { if (INTERNAL_EVIDENCE_KEY.equals(property)) { StringListProperty fields = (StringListProperty) variantObject.getField(property); if (fields == null || fields.getList().size() == 0) { return null; } return fields.getTextValue(); } else if (INTERNAL_START_POSITION_KEY.equals(property) || INTERNAL_END_POSITION_KEY.equals(property)) { int value = variantObject.getIntValue(property, -1); return value == -1 ? null : Integer.toString(value); } else { BaseStringProperty field = (BaseStringProperty) variantObject.getField(property); return field == null ? null : field.getValue(); } }
private String getFieldValue(BaseObject geneObject, String property) { if (INTERNAL_STRATEGY_KEY.equals(property)) { StringListProperty fields = (StringListProperty) geneObject.getField(property); if (fields == null || fields.getList().size() == 0) { return null; } return fields.getTextValue(); } else { BaseStringProperty field = (BaseStringProperty) geneObject.getField(property); if (field == null) { return null; } return field.getValue(); } }
private String getFieldValue(BaseObject variantObject, String property) { if (INTERNAL_EVIDENCE_KEY.equals(property)) { StringListProperty fields = (StringListProperty) variantObject.getField(property); if (fields == null || fields.getList().size() == 0) { return null; } return fields.getTextValue(); } else if (INTERNAL_START_POSITION_KEY.equals(property) || INTERNAL_END_POSITION_KEY.equals(property)) { int value = variantObject.getIntValue(property, -1); if (value == -1) { return null; } return Integer.toString(value); } else { BaseStringProperty field = (BaseStringProperty) variantObject.getField(property); if (field == null) { return null; } return field.getValue(); } }
private String getFieldValue(BaseObject geneObject, String property) { if (INTERNAL_STRATEGY_KEY.equals(property)) { StringListProperty fields = (StringListProperty) geneObject.getField(property); if (fields == null || fields.getList().size() == 0) { return null; } return fields.getTextValue(); } else { BaseStringProperty field = (BaseStringProperty) geneObject.getField(property); if (field == null) { return null; } return field.getValue(); } }
if (stringProperty.getValue() == null) { stringProperty.setValue("");