/** * @param baseObject the object containing the component definition * @param roleType the role Type implemented * @param roleHint the role hint for this role implementation */ public AbstractAsyncBaseObjectWikiComponent(BaseObject baseObject, Type roleType, String roleHint) { super(baseObject, roleType, roleHint); this.async = baseObject.getIntValue(XPROPERTY_ASYNC_ENABLED, 0) == 1; this.cached = baseObject.getIntValue(XPROPERTY_ASYNC_CACHED, 0) == 1; List<String> contextEntriesList = baseObject.getListValue(XPROPERTY_ASYNC_CONTEXT); this.contextEntries = contextEntriesList != null ? new HashSet<>(contextEntriesList) : null; } }
public int getIntValue(String fieldName) { BaseObject object = getFirstObject(fieldName, null); if (object == null) { return 0; } else { return object.getIntValue(fieldName); } }
/** * @since 2.2M2 */ public int getIntValue(DocumentReference classReference, String fieldName) { BaseObject obj = getXObject(classReference, 0); if (obj == null) { return 0; } return obj.getIntValue(fieldName); }
/** * Get the value of the field <code>fieldName</code> of the managed object's class. * * @param fieldName the name of the field from the managed object's class where to find the value. * @return the value in int of the field <code>fieldName</code> of the managed object's class. * @see com.xpn.xwiki.doc.XWikiDocument#getListValue(java.lang.String) */ public int getIntValue(String fieldName) { BaseObject obj = getBaseObject(false); if (obj == null) { return 0; } return obj.getIntValue(fieldName); }
public TableDataSource(BaseObject defObject, XWikiContext context) throws DataSourceException { init(defObject.getName(), defObject.getIntValue(TABLE_NUMBER), defObject.getStringValue(RANGE) == "" ? DEFAULT_RANGE : defObject.getStringValue(RANGE), defObject.getIntValue(HAS_HEADER_ROW) == 1, defObject .getIntValue(HAS_HEADER_COLUMN) == 1, defObject.getStringValue(DECIMAL_SYMBOL) == "" ? DEFAULT_DECIMAL_SYMBOL : defObject.getStringValue(DECIMAL_SYMBOL), defObject.getIntValue(IGNORE_ALPHA) == 1, context); }
private boolean areConsentsRequired(String clientProtocolVersion) { if (!ShareProtocol.ALLOW_NO_CONSENTS_PROTOCOL_VERSIONS.contains(clientProtocolVersion)) { return true; } // protocol is one of those which may be allowed to skip consents; now need to check if // not providing consents is allowed/configured in receive patient settings BaseObject mainConfig = getMainConfiguration(getXContext()); if (mainConfig != null && mainConfig.getIntValue(MAIN_CONFIG_ALLOW_NO_CONSENTS_FROM_OLD_CLIENTS) == 1) { return false; } return true; }
private boolean areConsentsRequired(String clientProtocolVersion) { if (!ShareProtocol.ALLOW_NO_CONSENTS_PROTOCOL_VERSIONS.contains(clientProtocolVersion)) { return true; } // protocol is one of those which may be allowed to skip consents; now need to check if // not providing consents is allowed/configured in receive patient settings BaseObject mainConfig = getMainConfiguration(getXContext()); if (mainConfig != null && mainConfig.getIntValue(MAIN_CONFIG_ALLOW_NO_CONSENTS_FROM_OLD_CLIENTS) == 1) { return false; } return true; }
@Override public boolean containsSensitiveData() { BaseObject familyObject = getXDocument().getXObject(Family.CLASS_REFERENCE); return (familyObject.getIntValue(FIELD_HAS_SENSITIVE_DATA) == FIELD_VALUE_CHECKED); }
private String getLifeStatus(BaseObject data) { String lifeStatus = ALIVE; Date date = data.getDateValue(DATE_OF_DEATH); String dodEntered = data.getStringValue(DATE_OF_DEATH_ENTERED); if (date != null || (StringUtils.isNotBlank(dodEntered) && !"{}".equals(dodEntered))) { lifeStatus = DECEASED; } else { // check if "unknown death date" checkbox is checked Integer deathDateUnknown = data.getIntValue(DATE_OF_DEATH_UNKNOWN); if (deathDateUnknown == 1) { lifeStatus = DECEASED; } } return lifeStatus; } }
private String getLifeStatus(BaseObject data) { String lifeStatus = ALIVE; Date date = data.getDateValue(DATE_OF_DEATH); String dodEntered = data.getStringValue(DATE_OF_DEATH_ENTERED); if (date != null || (StringUtils.isNotBlank(dodEntered) && !"{}".equals(dodEntered))) { lifeStatus = DECEASED; } else { // check if "unknown death date" checkbox is checked Integer deathDateUnknown = data.getIntValue(DATE_OF_DEATH_UNKNOWN); if (deathDateUnknown == 1) { lifeStatus = DECEASED; } } return lifeStatus; } }
@Override public String getWarningMessage() { BaseObject familyObject = this.familyDocument.getXObject(Family.CLASS_REFERENCE); if (familyObject.getIntValue(WARNING) == 0) { return ""; } else { return familyObject.getStringValue("warning_message"); } }
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(); } }
@Override public String getWarningMessage() { BaseObject familyObject = getXDocument().getXObject(Family.CLASS_REFERENCE); return familyObject.getIntValue(FIELD_HAS_SENSITIVE_DATA) == FIELD_VALUE_CHECKED ? familyObject.getStringValue("warning_message") : StringUtils.EMPTY; }
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(); } }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = patient.getXDocument(); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error(ERROR_MESSAGE_LOAD_FAILED, e.getMessage()); } return null; }
@Override public WikiPropertyGroup get(String wikiId) throws WikiPropertyGroupException { WikiTemplatePropertyGroup group = new WikiTemplatePropertyGroup(GROUP_NAME); try { XWikiDocument descriptorDocument = wikiDescriptorDocumentHelper.getDocumentFromWikiId(wikiId); // Get the object BaseObject object = descriptorDocument.getXObject(WikiTemplateClassDocumentInitializer.SERVER_CLASS); if (object != null) { group.setTemplate( object.getIntValue(WikiTemplateClassDocumentInitializer.FIELD_ISWIKITEMPLATE, 0) != 0); } } catch (WikiManagerException e) { throw new WikiPropertyGroupException(String.format(ERROR_MESSAGE_NO_DESCRIPTOR_DOCUMENT, wikiId), e); } return group; }
private void handleObject(List<NotificationFilterPreference> preferencesToConvert, BaseObject obj) { DefaultNotificationFilterPreference preference = new DefaultNotificationFilterPreference(); NotificationFilterType filterType = NotificationFilterType.valueOf( obj.getStringValue(FIELD_FILTER_TYPE).toUpperCase()); Set<NotificationFormat> filterFormats = new HashSet<>(); for (String format : (List<String>) obj.getListValue(FIELD_FILTER_FORMATS)) { filterFormats.add(NotificationFormat.valueOf(format.toUpperCase())); } preference.setProviderHint("userProfile"); preference.setFilterName(obj.getStringValue(FIELD_FILTER_NAME)); preference.setEnabled(obj.getIntValue(FIELD_IS_ENABLED, 1) == 1); preference.setActive(obj.getIntValue(FIELD_IS_ACTIVE, 1) == 1); preference.setFilterType(filterType); preference.setNotificationFormats(filterFormats); preference.setStartingDate(obj.getDateValue(FIELD_STARTING_DATE)); handleProperties(preferencesToConvert, obj, preference); }
@Override public boolean isServerTrusted() { // server is trusted if either "allow pushes from non-listed servers" is checked, // or the server is listed and thus have a configuration XWikiContext context = getXContext(); BaseObject mainConfig = getMainConfiguration(context); if (mainConfig == null) { this.logger.error("Receive configuration not found"); return false; } if (mainConfig.getIntValue(MAIN_CONFIG_ALLOW_ANY_SOURCE_PROPERTY_NAME) == 1) { return true; } BaseObject serverConfig = getSourceServerConfiguration(context.getRequest().getRemoteAddr(), context); if (serverConfig == null) { this.logger.error("Connection from an untrusted server {}", context.getRequest().getRemoteAddr()); return false; } return true; }
@Override public PatientData<String> load(Patient patient) { try { XWikiDocument doc = (XWikiDocument) this.documentAccessBridge.getDocument(patient.getDocument()); BaseObject data = doc.getXObject(Patient.CLASS_REFERENCE); if (data == null) { return null; } int isNormal = data.getIntValue(PATIENT_DOCUMENT_FIELDNAME); if (isNormal == 0) { return new SimpleValuePatientData<>(getName(), VALUE_AFFECTED); } else if (isNormal == 1) { return new SimpleValuePatientData<>(getName(), VALUE_UNAFFECTED); } } catch (Exception e) { this.logger.error("Could not find requested document or some unforeseen" + " error has occurred during controller loading ", e.getMessage()); } return null; }
@Override public boolean isServerTrusted() { // server is trusted if either "allow pushes from non-listed servers" is checked, // or the server is listed and thus have a configuration XWikiContext context = getXContext(); BaseObject mainConfig = getMainConfiguration(context); if (mainConfig == null) { this.logger.error("Receive configuration not found"); return false; } if (mainConfig.getIntValue(MAIN_CONFIG_ALLOW_ANY_SOURCE_PROPERTY_NAME) == 1) { return true; } BaseObject serverConfig = getSourceServerConfiguration(context.getRequest().getRemoteAddr(), context); if (serverConfig == null) { this.logger.error("Connection from an untrusted server {}", context.getRequest().getRemoteAddr()); return false; } return true; }