internal PropagateStoreGeneratedPatternToStorageModel( CommandProcessorContext cpc, StorageProperty storageProperty, bool propagateNoneSGP) { _cpc = cpc; _storageProperty = storageProperty; _propagateNoneSGP = propagateNoneSGP; }
private bool InnerNext() { if (_txStateChangedProperties != null) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: if (_txStateChangedProperties.hasNext()) { //JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops: _txStateValue = _txStateChangedProperties.next(); return(true); } else { _txStateChangedProperties = null; _txStateValue = null; } } while (_storeCursor.next()) { bool skip = _propertiesState != null && _propertiesState.isPropertyChangedOrRemoved(_storeCursor.propertyKey()); if (!skip) { return(true); } } return(false); }
private static Property CreateStorageProperty(StorageEntityType parentEntity, string name, string type) { var property = new StorageProperty(parentEntity, null); property.LocalName.Value = name; property.Type.Value = type; return(property); }
public override void Close() { if (!Closed) { _propertiesState = null; _txStateChangedProperties = null; _txStateValue = null; _read = null; _storeCursor.reset(); _pool.accept(this); } }
public override void VisitNodePropertyChanges(long id, IEnumerator <StorageProperty> added, IEnumerator <StorageProperty> changed, IntIterable removed) { removed.each(propId => _recordState.nodeRemoveProperty(id, propId)); while (changed.MoveNext()) { StorageProperty prop = changed.Current; _recordState.nodeChangeProperty(id, prop.PropertyKeyId(), prop.Value()); } while (added.MoveNext()) { StorageProperty prop = added.Current; _recordState.nodeAddProperty(id, prop.PropertyKeyId(), prop.Value()); } }
public override void VisitGraphPropertyChanges(IEnumerator <StorageProperty> added, IEnumerator <StorageProperty> changed, IntIterable removed) { removed.each(_recordState.graphRemoveProperty); while (changed.MoveNext()) { StorageProperty prop = changed.Current; _recordState.graphChangeProperty(prop.PropertyKeyId(), prop.Value()); } while (added.MoveNext()) { StorageProperty prop = added.Current; _recordState.graphAddProperty(prop.PropertyKeyId(), prop.Value()); } }
/// <summary> /// Updates a single property on an existing object /// </summary> /// <param name="id">ObjectId</param> /// <param name="propertyName"></param> /// <param name="propertyValue"></param> /// <param name="callback"></param> /// <returns></returns> public void UpdateProperty(string id, string propertyName, string propertyValue, Action <Response> callback) { if (!IsAuthenticated) { callback(new Response(new Exception("Not authenticated"))); return; } var model = new StorageProperty { ObjectId = id, PropertyName = propertyName, PropertyValue = propertyValue, }; HttpPostAsync("UpdateProperty", model, callback); }
public async Task <IHttpActionResult> UpdateProperty(StorageProperty model) { var entity = await AppDatabase.Storage.FindAsync(model.ObjectId); if (entity == null) { return(Ok()); } // ACL switch (entity.AclType) { case StorageACLType.Admin: if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } break; case StorageACLType.User: if (UserId != entity.AclParam) { return(Unauthorized()); } break; } var data = entity.GetData(); data[model.PropertyName] = model.PropertyValue; entity.ObjectData = data.ToString(); entity.ModifiedOn = DateTime.UtcNow; // Context.Update(entity); await AppDatabase.SaveChangesAsync(); return(Ok()); }
/// <summary> /// LUA结构支持 /// </summary> /// <returns></returns> public override void GetLuaStruct(StringBuilder code) { base.GetLuaStruct(code); int idx; if (!string.IsNullOrWhiteSpace(PropertyName)) { code.AppendLine($@"['PropertyName'] = '{PropertyName.ToLuaString()}',"); } else { code.AppendLine($@"['PropertyName'] = nil,"); } code.AppendLine($@"['IsCaption'] ={(IsCaption.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Alias)) { code.AppendLine($@"['Alias'] = '{Alias.ToLuaString()}',"); } else { code.AppendLine($@"['Alias'] = nil,"); } if (!string.IsNullOrWhiteSpace(Group)) { code.AppendLine($@"['Group'] = '{Group.ToLuaString()}',"); } else { code.AppendLine($@"['Group'] = nil,"); } code.AppendLine($@"['CreateIndex'] ={(CreateIndex.ToString().ToLower())},"); code.AppendLine($@"['IsPrimaryKey'] ={(IsPrimaryKey.ToString().ToLower())},"); code.AppendLine($@"['IsExtendKey'] ={(IsExtendKey.ToString().ToLower())},"); code.AppendLine($@"['IsIdentity'] ={(IsIdentity.ToString().ToLower())},"); code.AppendLine($@"['IsGlobalKey'] ={(IsGlobalKey.ToString().ToLower())},"); code.AppendLine($@"['UniqueIndex'] ={UniqueIndex},"); code.AppendLine($@"['IsRequired'] ={(IsRequired.ToString().ToLower())},"); code.AppendLine($@"['IsUserReadOnly'] ={(IsUserReadOnly.ToString().ToLower())},"); code.AppendLine($@"['IsMemo'] ={(IsMemo.ToString().ToLower())},"); code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Prefix)) { code.AppendLine($@"['Prefix'] = '{Prefix.ToLuaString()}',"); } else { code.AppendLine($@"['Prefix'] = nil,"); } if (!string.IsNullOrWhiteSpace(Suffix)) { code.AppendLine($@"['Suffix'] = '{Suffix.ToLuaString()}',"); } else { code.AppendLine($@"['Suffix'] = nil,"); } if (!string.IsNullOrWhiteSpace(InputType)) { code.AppendLine($@"['InputType'] = '{InputType.ToLuaString()}',"); } else { code.AppendLine($@"['InputType'] = nil,"); } if (!string.IsNullOrWhiteSpace(ComboBoxUrl)) { code.AppendLine($@"['ComboBoxUrl'] = '{ComboBoxUrl.ToLuaString()}',"); } else { code.AppendLine($@"['ComboBoxUrl'] = nil,"); } code.AppendLine($@"['IsMoney'] ={(IsMoney.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(GridAlign)) { code.AppendLine($@"['GridAlign'] = '{GridAlign.ToLuaString()}',"); } else { code.AppendLine($@"['GridAlign'] = nil,"); } if (!string.IsNullOrWhiteSpace(DataFormater)) { code.AppendLine($@"['DataFormater'] = '{DataFormater.ToLuaString()}',"); } else { code.AppendLine($@"['DataFormater'] = nil,"); } code.AppendLine($@"['DenyClient'] ={(DenyClient.ToString().ToLower())},"); code.AppendLine($@"['GridDetails'] ={(GridDetails.ToString().ToLower())},"); code.AppendLine($@"['NoneGrid'] ={(NoneGrid.ToString().ToLower())},"); code.AppendLine($@"['NoneDetails'] ={(NoneDetails.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(GridDetailsCode)) { code.AppendLine($@"['GridDetailsCode'] = '{GridDetailsCode.ToLuaString()}',"); } else { code.AppendLine($@"['GridDetailsCode'] = nil,"); } if (!string.IsNullOrWhiteSpace(CppType)) { code.AppendLine($@"['CppType'] = '{CppType.ToLuaString()}',"); } else { code.AppendLine($@"['CppType'] = nil,"); } if (CppTypeObject != null) { code.AppendLine($@"['CppTypeObject'] ='{CppTypeObject}',"); } if (!string.IsNullOrWhiteSpace(CppName)) { code.AppendLine($@"['CppName'] = '{CppName.ToLuaString()}',"); } else { code.AppendLine($@"['CppName'] = nil,"); } if (!string.IsNullOrWhiteSpace(CppLastType)) { code.AppendLine($@"['CppLastType'] = '{CppLastType.ToLuaString()}',"); } else { code.AppendLine($@"['CppLastType'] = nil,"); } code.AppendLine($@"['IsIntDecimal'] ={(IsIntDecimal.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(CsType)) { code.AppendLine($@"['CsType'] = '{CsType.ToLuaString()}',"); } else { code.AppendLine($@"['CsType'] = nil,"); } if (!string.IsNullOrWhiteSpace(CustomType)) { code.AppendLine($@"['CustomType'] = '{CustomType.ToLuaString()}',"); } else { code.AppendLine($@"['CustomType'] = nil,"); } if (!string.IsNullOrWhiteSpace(LastCsType)) { code.AppendLine($@"['LastCsType'] = '{LastCsType.ToLuaString()}',"); } else { code.AppendLine($@"['LastCsType'] = nil,"); } if (EnumConfig != null) { code.AppendLine($@"['EnumConfig'] = {EnumConfig.GetLuaStruct()},"); } code.AppendLine($@"['IsCompute'] ={(IsCompute.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ComputeGetCode)) { code.AppendLine($@"['ComputeGetCode'] = '{ComputeGetCode.ToLuaString()}',"); } else { code.AppendLine($@"['ComputeGetCode'] = nil,"); } if (!string.IsNullOrWhiteSpace(ComputeSetCode)) { code.AppendLine($@"['ComputeSetCode'] = '{ComputeSetCode.ToLuaString()}',"); } else { code.AppendLine($@"['ComputeSetCode'] = nil,"); } code.AppendLine($@"['IsMiddleField'] ={(IsMiddleField.ToString().ToLower())},"); code.AppendLine($@"['InnerField'] ={(InnerField.ToString().ToLower())},"); code.AppendLine($@"['IsSystemField'] ={(IsSystemField.ToString().ToLower())},"); code.AppendLine($@"['IsInterfaceField'] ={(IsInterfaceField.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Initialization)) { code.AppendLine($@"['Initialization'] = '{Initialization.ToLuaString()}',"); } else { code.AppendLine($@"['Initialization'] = nil,"); } if (!string.IsNullOrWhiteSpace(EmptyValue)) { code.AppendLine($@"['EmptyValue'] = '{EmptyValue.ToLuaString()}',"); } else { code.AppendLine($@"['EmptyValue'] = nil,"); } code.AppendLine($@"['DenyScope'] ='{DenyScope}',"); code.AppendLine($@"['Nullable'] ={(Nullable.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Max)) { code.AppendLine($@"['Max'] = '{Max.ToLuaString()}',"); } else { code.AppendLine($@"['Max'] = nil,"); } if (!string.IsNullOrWhiteSpace(Min)) { code.AppendLine($@"['Min'] = '{Min.ToLuaString()}',"); } else { code.AppendLine($@"['Min'] = nil,"); } code.AppendLine($@"['UniqueString'] ={(UniqueString.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ColumnName)) { code.AppendLine($@"['ColumnName'] = '{ColumnName.ToLuaString()}',"); } else { code.AppendLine($@"['ColumnName'] = nil,"); } code.AppendLine($@"['DbNullable'] ={(DbNullable.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(DbType)) { code.AppendLine($@"['DbType'] = '{DbType.ToLuaString()}',"); } else { code.AppendLine($@"['DbType'] = nil,"); } code.AppendLine($@"['Precision'] ={Datalen},"); if (!string.IsNullOrWhiteSpace(ArrayLen)) { code.AppendLine($@"['ArrayLen'] = '{ArrayLen.ToLuaString()}',"); } else { code.AppendLine($@"['ArrayLen'] = nil,"); } code.AppendLine($@"['Scale'] ={Scale},"); code.AppendLine($@"['DbIndex'] ={DbIndex},"); code.AppendLine($@"['Unicode'] ={(Unicode.ToString().ToLower())},"); code.AppendLine($@"['FixedLength'] ={(FixedLength.ToString().ToLower())},"); code.AppendLine($@"['IsBlob'] ={(IsBlob.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(StorageProperty)) { code.AppendLine($@"['StorageProperty'] = '{StorageProperty.ToLuaString()}',"); } else { code.AppendLine($@"['StorageProperty'] = nil,"); } code.AppendLine($@"['DbInnerField'] ={(DbInnerField.ToString().ToLower())},"); code.AppendLine($@"['NoStorage'] ={(NoStorage.ToString().ToLower())},"); code.AppendLine($@"['KeepStorageScreen'] ='{KeepStorageScreen}',"); code.AppendLine($@"['CustomWrite'] ={(CustomWrite.ToString().ToLower())},"); code.AppendLine($@"['IsLinkField'] ={(IsLinkField.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(LinkTable)) { code.AppendLine($@"['LinkTable'] = '{LinkTable.ToLuaString()}',"); } else { code.AppendLine($@"['LinkTable'] = nil,"); } code.AppendLine($@"['IsLinkKey'] ={(IsLinkKey.ToString().ToLower())},"); code.AppendLine($@"['IsLinkCaption'] ={(IsLinkCaption.ToString().ToLower())},"); code.AppendLine($@"['IsUserId'] ={(IsUserId.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(LinkField)) { code.AppendLine($@"['LinkField'] = '{LinkField.ToLuaString()}',"); } else { code.AppendLine($@"['LinkField'] = nil,"); } code.AppendLine($@"['IsCustomCompute'] ={(IsCustomCompute.ToString().ToLower())},"); code.AppendLine($@"['CanGet'] ={(CanGet.ToString().ToLower())},"); code.AppendLine($@"['CanSet'] ={(CanSet.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(AccessType)) { code.AppendLine($@"['AccessType'] = '{AccessType.ToLuaString()}',"); } else { code.AppendLine($@"['AccessType'] = nil,"); } code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},"); code.AppendLine($@"['CanInput'] ={(CanUserInput.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ExtendRole)) { code.AppendLine($@"['ExtendRole'] = '{ExtendRole.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendRole'] = nil,"); } if (!string.IsNullOrWhiteSpace(ValueSeparate)) { code.AppendLine($@"['ValueSeparate'] = '{ValueSeparate.ToLuaString()}',"); } else { code.AppendLine($@"['ValueSeparate'] = nil,"); } if (!string.IsNullOrWhiteSpace(ArraySeparate)) { code.AppendLine($@"['ArraySeparate'] = '{ArraySeparate.ToLuaString()}',"); } else { code.AppendLine($@"['ArraySeparate'] = nil,"); } code.AppendLine($@"['ExtendArray'] ={(ExtendArray.ToString().ToLower())},"); code.AppendLine($@"['IsKeyValueArray'] ={(IsKeyValueArray.ToString().ToLower())},"); code.AppendLine($@"['IsRelation'] ={(IsRelation.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(ExtendPropertyName)) { code.AppendLine($@"['ExtendPropertyName'] = '{ExtendPropertyName.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendPropertyName'] = nil,"); } if (!string.IsNullOrWhiteSpace(ExtendClassName)) { code.AppendLine($@"['ExtendClassName'] = '{ExtendClassName.ToLuaString()}',"); } else { code.AppendLine($@"['ExtendClassName'] = nil,"); } code.AppendLine($@"['ExtendClassIsPredestinate'] ={(ExtendClassIsPredestinate.ToString().ToLower())},"); code.AppendLine($@"['IsRelationField'] ={(IsRelationField.ToString().ToLower())},"); code.AppendLine($@"['IsRelationValue'] ={(IsRelationValue.ToString().ToLower())},"); code.AppendLine($@"['IsRelationArray'] ={(IsRelationArray.ToString().ToLower())},"); code.AppendLine($@"['IsExtendArray'] ={(IsExtendArray.ToString().ToLower())},"); code.AppendLine($@"['IsExtendValue'] ={(IsExtendValue.ToString().ToLower())},"); }
private void PropagateConceptualSGPToStorageProperty(StorageProperty sProp) { if (null == sProp) { Debug.Fail("null StorageProperty"); return; } if (sProp.IsDisposed) { // this StorageProperty was deleted after this integrity check was created but // before it was invoked - not an error - just ignore this property return; } if (sProp.IsKeyProperty) { if (IsStorageForNonRootEntityType(sProp)) { // this StorageProperty is for a key column on a table which acts as storage for a non-root EntityType // (e.g. in a TPT hierarchy). So do not set SGP - it should be set only on the root column. return; } if (IsDependentSidePropertyInAssociation(sProp)) { // this StorageProperty is used in the dependent side of an Association. // So do not set SGP - it should be set only on the principal side. return; } } // loop over ConceptualProperties mapped to this StorageProperty foreach (var sp in sProp.GetAntiDependenciesOfType <ScalarProperty>()) { // only use ScalarProperty elements inside an EntitySetMapping or EntityTypeMapping // (MappingFragment is only used by those types of mappings) if (null != sp.GetParentOfType(typeof(MappingFragment))) { // only propagate values from non-key C-side properties var cProp = sp.Name.Target as ConceptualProperty; if (cProp != null) { var cSideSGPValue = cProp.StoreGeneratedPattern.Value; if (_propagateNoneSGP || false == ModelConstants.StoreGeneratedPattern_None.Equals(cSideSGPValue, StringComparison.Ordinal)) { // have found a C-side property whose SGP value should be propagated if (false == cSideSGPValue.Equals(sProp.StoreGeneratedPattern.Value, StringComparison.Ordinal)) { var cmd = new UpdateDefaultableValueCommand <string>(sProp.StoreGeneratedPattern, cSideSGPValue); CommandProcessor.InvokeSingleCommand(_cpc, cmd); } return; } // Otherwise have found a C-side SGP but it has value "None" and have been told not to propagate "None" values // (will apply to where SGP is absent too since "None" is the default value). // So loop round looking for the next C-side SGP to see if it applies. } } } }
private void TakeSnapshot() { try { using (StorageNodeCursor node = _store.allocateNodeCursor(), StoragePropertyCursor properties = _store.allocatePropertyCursor(), StorageRelationshipScanCursor relationship = _store.allocateRelationshipScanCursor()) { TokenRead tokenRead = _transaction.tokenRead(); _state.addedAndRemovedNodes().Removed.each(nodeId => { node.Single(nodeId); if (node.Next()) { properties.Init(node.PropertiesReference()); while (properties.Next()) { try { _removedNodeProperties.Add(new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(properties.PropertyKey()), null, properties.PropertyValue())); } catch (PropertyKeyIdNotFoundKernelException e) { throw new System.InvalidOperationException("Nonexisting properties was modified for node " + nodeId, e); } } foreach (long labelId in node.Labels()) { try { _removedLabels.Add(new LabelEntryView(this, nodeId, tokenRead.NodeLabelName(toIntExact(labelId)))); } catch (LabelNotFoundKernelException e) { throw new System.InvalidOperationException("Nonexisting label was modified for node " + nodeId, e); } } } }); _state.addedAndRemovedRelationships().Removed.each(relId => { Relationship relationshipProxy = relationship(relId); relationship.Single(relId); if (relationship.Next()) { properties.Init(relationship.PropertiesReference()); while (properties.Next()) { try { _removedRelationshipProperties.Add(new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(properties.PropertyKey()), null, properties.PropertyValue())); } catch (PropertyKeyIdNotFoundKernelException e) { throw new System.InvalidOperationException("Nonexisting node properties was modified for relationship " + relId, e); } } } }); foreach (NodeState nodeState in _state.modifiedNodes()) { IEnumerator <StorageProperty> added = nodeState.AddedAndChangedProperties(); long nodeId = nodeState.Id; while (added.MoveNext()) { StorageProperty property = added.Current; _assignedNodeProperties.Add(new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(property.PropertyKeyId()), property.Value(), CommittedValue(nodeState, property.PropertyKeyId(), node, properties))); } nodeState.RemovedProperties().each(id => { try { NodePropertyEntryView entryView = new NodePropertyEntryView(this, nodeId, tokenRead.PropertyKeyName(id), null, CommittedValue(nodeState, id, node, properties)); _removedNodeProperties.Add(entryView); } catch (PropertyKeyIdNotFoundKernelException e) { throw new System.InvalidOperationException("Nonexisting node properties was modified for node " + nodeId, e); } }); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.storageengine.api.txstate.LongDiffSets labels = nodeState.labelDiffSets(); LongDiffSets labels = nodeState.LabelDiffSets(); AddLabelEntriesTo(nodeId, labels.Added, _assignedLabels); AddLabelEntriesTo(nodeId, labels.Removed, _removedLabels); } foreach (RelationshipState relState in _state.modifiedRelationships()) { Relationship relationshipProxy = relationship(relState.Id); IEnumerator <StorageProperty> added = relState.AddedAndChangedProperties(); while (added.MoveNext()) { StorageProperty property = added.Current; _assignedRelationshipProperties.Add(new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(property.PropertyKeyId()), property.Value(), CommittedValue(relState, property.PropertyKeyId(), relationship, properties))); } relState.RemovedProperties().each(id => { try { RelationshipPropertyEntryView entryView = new RelationshipPropertyEntryView(relationshipProxy, tokenRead.PropertyKeyName(id), null, CommittedValue(relState, id, relationship, properties)); _removedRelationshipProperties.Add(entryView); } catch (PropertyKeyIdNotFoundKernelException e) { throw new System.InvalidOperationException("Nonexisting properties was modified for relationship " + relState.Id, e); } }); } } } catch (PropertyKeyIdNotFoundKernelException e) { throw new System.InvalidOperationException("An entity that does not exist was modified.", e); } }
set => SetValue(StorageProperty, value);