private boolean isValidIdentifiable(Object val) { if (!(val instanceof OIdentifiable)) { return false; } return ((OIdentifiable) val).getIdentity().isPersistent(); }
protected boolean useQueryProvider() { ODocument doc = docModel.getObject(); return doc.getIdentity().isPersistent(); }
protected boolean useQueryProvider() { ODocument doc = docModel.getObject(); return doc.getIdentity().isPersistent(); }
@Override public boolean isPersistent() { session.checkOpen(); return document.getIdentity().isPersistent(); }
protected void manageNeedRetryException(OBaseWorkLoadContext context, ONeedRetryException e) { if (((OWorkLoadContext) context).lastVertexToConnect.getIdentity().isPersistent()) ((OWorkLoadContext) context).lastVertexToConnect.reload(); }
@Override public OIdentifiable convert(OIdentifiable value) { final ORID rid = value.getIdentity(); if (!rid.isPersistent()) return value; if (converterData.brokenRids.contains(rid)) return OImportConvertersFactory.BROKEN_LINK; final OIdentifiable newRid = converterData.exportImportHashTable.get(rid); if (newRid == null) return value; return newRid.getIdentity(); } }
/** * Atomic increment number field value * @param field * @param value */ public void incrementField(final String field, final Number value){ Number oldValue = document.field(field); document.field(field, oldValue.doubleValue()+value.doubleValue()); if(document.getIdentity().isPersistent()) { atomicChange(field,value,"INCREMENT "+field+"=?"); } }
protected void rawField(final String iFieldName, final Object iFieldValue, final OType iFieldType) { if (_fields == null) _fields = _ordered ? new LinkedHashMap<>() : new HashMap<>(); ODocumentEntry entry = getOrCreate(iFieldName); removeCollectionChangeListener(entry, entry.value); entry.value = iFieldValue; entry.type = iFieldType; addCollectionChangeListener(entry); if (iFieldValue instanceof OIdentifiable && !((OIdentifiable) iFieldValue).getIdentity().isPersistent()) track((OIdentifiable) iFieldValue); }
@Override public String convertToString(ODocument value, Locale locale) { return value.getIdentity().isPersistent() ? super.convertToString(value, locale):value.toJSON(); }
/** * Atomic set field value * @param field * @param value */ public <V> void setField(final String field, final V value){ document.field(field, value); if(document.getIdentity().isPersistent()) { atomicChange(field,value,"SET "+field+"=?"); } } /**
@Override public ORID map(ORID rid) { if (rid == null) return null; if (!rid.isPersistent()) return null; databaseTwo.activateOnCurrentThread(); final OIdentifiable result = exportImportHashTable.get(rid); if (result == null) return null; return result.getIdentity(); } };
public <T> T getProperty(String name) { T result = null; if (content.containsKey(name)) { result = (T) wrap(content.get(name)); } else if (element != null) { result = (T) wrap(((ODocument) element.getRecord()).getProperty(name)); } if (result instanceof OIdentifiable && ((OIdentifiable) result).getIdentity().isPersistent()) { result = (T) ((OIdentifiable) result).getIdentity(); } return result; }
/** * Atomic append string field value * @param field * @param value */ public void appendField(final String field, final String value){ String oldValue = document.field(field); document.field(field, oldValue+value); if(document.getIdentity().isPersistent()) { atomicChange(field,value,"SET "+field+"=ifnull("+field+",'').append(?)"); } }
@Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { ODocument doc = getWidgetDocument(); if(doc.getIdentity().isPersistent()) { setResponsePage(new ODocumentPage(doc)); } else if(targetOptional.isPresent()){ String alert = "alert('"+JavaScriptUtils.escapeQuotes(getLocalizer().getString("warning.widget.nosettings", AbstractWidget.this))+"')"; targetOptional.get().appendJavaScript(alert); } } });
private Object extractValue(ODocument record, OPair<String, Object> entry) { Object value = entry.getValue(); if (value instanceof OSQLFilterItem) value = ((OSQLFilterItem) value).getValue(record, null, context); else if (value instanceof OCommandRequest) value = ((OCommandRequest) value).execute(record, null, context); if (value instanceof OIdentifiable && ((OIdentifiable) value).getIdentity().isPersistent()) // USE ONLY THE RID TO AVOID CONCURRENCY PROBLEM WITH OLD VERSIONS value = ((OIdentifiable) value).getIdentity(); return value; }
@Override public boolean add(OIdentifiable e) { if (e != null) { if ((ridOnly || contentType == MULTIVALUE_CONTENT_TYPE.ALL_RIDS) && e.getIdentity().isPersistent() && (e instanceof ODocument && !((ODocument) e).isDirty())) // IT'S BETTER TO LEAVE ALL RIDS AND EXTRACT ONLY THIS ONE e = e.getIdentity(); else contentType = ORecordMultiValueHelper.updateContentType(contentType, e); } lazyLoad(true); return super.add(e); }
@Override protected void onConfigure() { super.onConfigure(); setVisible(getModelObject().getIdentity().isPersistent() || getModeObject().canModify()); }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }
private int writeOptimizedLink(final BytesContainer bytes, OIdentifiable link) { if (!link.getIdentity().isPersistent()) { final ORecord real = link.getRecord(); if (real != null) link = real; } final int pos = OVarIntSerializer.write(bytes, link.getIdentity().getClusterId()); OVarIntSerializer.write(bytes, link.getIdentity().getClusterPosition()); return pos; }