/*
MATCH (owner:ENTITY:Account {login: {0}}) -[:type]-> (e:EMBEDDED)
REMOVE e.property
172897
private Map<String, String> initRemoveEmbeddedPropertyQuery(EntityKeyMetadata entityKeyMetadata, TupleTypeContext tupleTypeContext) {
		if ( tupleTypeContext == null ) {
			return Collections.emptyMap();
		}
		Map<String, String> removeColumn = new HashMap<>();
		for ( String column : tupleTypeContext.getSelectableColumns() ) {
			if ( EmbeddedHelper.isPartOfEmbedded( column ) ) {
				if ( !removeColumn.containsKey( column ) ) {
					StringBuilder queryBuilder = new StringBuilder();
					queryBuilder.append( "MATCH " );
					appendEntityNode( "n", entityKeyMetadata, queryBuilder );
					String[] path = EmbeddedHelper.split( column );
					for ( int i = 0; i < path.length - 1; i++ ) {
						queryBuilder.append( "-[:" );
						appendRelationshipType( queryBuilder, path[i] );
						queryBuilder.append( "]->" );
						if ( i == path.length - 2 ) {
							queryBuilder.append( "(e:EMBEDDED) " );
						}
						else {
							queryBuilder.append( "(:EMBEDDED) " );
						}
					}
					queryBuilder.append( "REMOVE e." );
					escapeIdentifier( queryBuilder, path[path.length - 1] );
					queryBuilder.append( " WITH e " );
					queryBuilder.append( "MATCH (e)<-[erel]-(a) " );
					queryBuilder.append( "WHERE length(keys(e))=0 AND NOT ((e)-->()) " );
					queryBuilder.append( "DELETE e, erel " );
					queryBuilder.append( "WITH a " );
					queryBuilder.append( "OPTIONAL MATCH path=(a)<-[r*]-(b:EMBEDDED), (b)<-[brel]-(), (x) " );
					queryBuilder.append( "WHERE a:EMBEDDED AND length(keys(a))=0 AND NOT((a)<-[*]-(:EMBEDDED)-->())  AND NOT ((a)<-[*]-(x)<-[*]-(b)) AND length(keys(b))>0 " );
					queryBuilder.append( "FOREACH (r in relationships(path) | DELETE r) " );
					queryBuilder.append( "FOREACH (n in nodes(path) | DELETE n) " );
					queryBuilder.append( "WITH a " );
					queryBuilder.append( "MATCH (a)<-[arel]-() " );
					queryBuilder.append( "WHERE length(keys(a))=0 AND a:EMBEDDED " );
					queryBuilder.append( "DELETE arel, a " );
					removeColumn.put( column, queryBuilder.toString() );
				}
			}
		}
		return Collections.unmodifiableMap( removeColumn );
	}
662866
protected static void appendMatchOwnerEntityNode(StringBuilder queryBuilder, EntityKeyMetadata ownerEntityKeyMetadata) {
		queryBuilder.append( "MATCH " );
		appendEntityNode( "owner", ownerEntityKeyMetadata, queryBuilder );
	}
685632
function normalizeEntities(base, input) {
  if (!input) return;
  if (!Array.isArray(input)) input = [ input ];

  return flatten(input).filter(Boolean).map(function (entity) {
    assert(entity.rel, 'sub-entities must have a rel');

    var ret = normalizeEntity(base, entity);
    ret.rel = normalizeRel(base, entity.rel);
    if (entity.href) ret.href = normalizeHref(base, entity.href);

    return ret;
  });
}
1260632
public boolean remove(DbEntity e) {
    Class<?> cacheKey = cacheKeyMapping.getEntityCacheKey(e.getClass());
    Map<String, CachedDbEntity> typeMap = cachedEntites.get(cacheKey);
    if(typeMap != null) {
      return typeMap.remove(e.getId()) != null;
    } else {
      return false;
    }
  }
175305
function(matchIndex) {
		var oldToken = this.matchesLookup[matchIndex].token;
		for (var j=0;j<this.matchesLookup.length;++j) {
			this.matchesLookup[j].usedBy = this.matchesLookup[j].usedBy.split(oldToken).join("");
		}
		this.matchesLookup[matchIndex].cleared=true;
	}
784693
function checkIfMatch(req, res, next) {
    var clientETags;
    var cur;
    var etag = res.etag || res.getHeader('etag') || '';
    var ifMatch;
    var matched = false;

    if ((ifMatch = req.headers['if-match'])) {

        clientETags = ifMatch.split(/\s*,\s*/);

        for (var i = 0; i < clientETags.length; i++) {
            cur = clientETags[i];

            // only strong comparison

            cur = cur.replace(/^W\//, '');
            cur = cur.replace(/^"(\w*)"$/, '$1');

            if (cur === '*' || cur === etag) {
                matched = true;
                break;
            }
        }

        if (!matched) {
            var err = new PreconditionFailedError(IF_MATCH_FAIL,
                ifMatch,
                etag);
            return (next(err));
        }
    }

    return (next());
}
733972
private void removePropertyForEmbedded(Node embeddedNode, String[] embeddedColumnSplit, int i) {
		if ( i == embeddedColumnSplit.length - 1 ) {
			// Property
			String property = embeddedColumnSplit[embeddedColumnSplit.length - 1];
			if ( embeddedNode.hasProperty( property ) ) {
				embeddedNode.removeProperty( property );
			}
		}
		else {
			Iterator<Relationship> iterator = embeddedNode.getRelationships( Direction.OUTGOING, withName( embeddedColumnSplit[i] ) ).iterator();
			if ( iterator.hasNext() ) {
				removePropertyForEmbedded( iterator.next().getEndNode(), embeddedColumnSplit, i + 1 );
			}
		}
		if ( !embeddedNode.getPropertyKeys().iterator().hasNext() ) {
			// Node without properties
			Iterator<Relationship> iterator = embeddedNode.getRelationships().iterator();
			if ( iterator.hasNext() ) {
				Relationship relationship = iterator.next();
				if ( !iterator.hasNext() ) {
					// Node with only one relationship and no properties,
					// we can remove it:
					// It means we have removed all the properties from the embedded node
					// and it is NOT an intermediate node like
					// (entity) --> (embedded1) --> (embedded2)
					relationship.delete();
					embeddedNode.delete();
				}
			}
		}
	}
760781
function(e, regex) {
    var endOfSearchMarkerNode = this._getNextNode(e, true);
    var next = this._getNextNode(e);
    while (next && next != endOfSearchMarkerNode) {
      if (regex.test(next.className + " " + next.id)) {
        next = this._removeAndGetNext(next);
      } else {
        next = this._getNextNode(next);
      }
    }
  }
239572
private static String initRemoveEntityQuery(EntityKeyMetadata entityKeyMetadata) {
		StringBuilder queryBuilder = new StringBuilder( "MATCH " );
		appendEntityNode( "n", entityKeyMetadata, queryBuilder );
		queryBuilder.append( " OPTIONAL MATCH (n)-[r]->(e:EMBEDDED), path=(e)-[*0..]->(:EMBEDDED) " );
		queryBuilder.append( " DELETE r " );
		queryBuilder.append( " FOREACH (er IN relationships(path) | DELETE er) " );
		queryBuilder.append( " FOREACH (en IN nodes(path) | DELETE en) " );
		queryBuilder.append( " WITH n " );
		queryBuilder.append( " OPTIONAL MATCH (n)-[r]-() " );
		queryBuilder.append( " DELETE r,n " );
		return queryBuilder.toString();
	}
1304744
function(entityData) {
    // Avoid updating components if the entity data received did not come from the current owner.
    if (entityData.lastOwnerTime < this.lastOwnerTime ||
          (this.lastOwnerTime === entityData.lastOwnerTime && this.data.owner > entityData.owner)) {
      return;
    }

    if (this.data.owner !== entityData.owner) {
      var wasMine = this.isMine();
      this.lastOwnerTime = entityData.lastOwnerTime;

      const oldOwner = this.data.owner;
      const newOwner = entityData.owner;
      if (wasMine) {
        this.onOwnershipLostEvent.newOwner = newOwner;
        this.el.emit(this.OWNERSHIP_LOST, this.onOwnershipLostEvent);
      }
      this.onOwnershipChangedEvent.oldOwner = oldOwner;
      this.onOwnershipChangedEvent.newOwner = newOwner;
      this.el.emit(this.OWNERSHIP_CHANGED, this.onOwnershipChangedEvent);

      this.el.setAttribute('networked', { owner: entityData.owner });
    }
    this.updateComponents(entityData.components);
  }
334392
function Match(path, route, match, query, valueDecoders) {
  this.path = path;
  this.route = route;
  this.match = match;
  this.query = query;

  if (valueDecoders) {
    Object.keys(match || {}).forEach(function(key) {
      if (typeof valueDecoders === 'function') {
        match[key] = valueDecoders(key, match[key]);
        return;
      }
      var fn = valueDecoders.hasOwnProperty(key) && valueDecoders[key];
      if (typeof fn === 'function') {
        match[key] = fn(match[key]);
      }
    });
  }

  this.unmatchedPath = this.match && this.match._ ?
    this.match._[0] :
    null;

  this.matchedPath = this.unmatchedPath ?
    this.path.substring(0, this.path.length - this.unmatchedPath.length) :
    this.path;
}
713081
function matchToHolders(match, tag) {
  return object(match.map(function(val, index) {
    return [tag+":"+index, val];
  }));
}
888350
function( object, propertyTable, eid ) {

		// Create a new BST for this entity for by-value matching
		if (this.indexVal[eid] === undefined)
			this.indexVal[eid] = new BinarySearchTree({
				compareKeys: objectBstComparison,
				checkValueEquality: objectBstEquals,
				unique: true,
			});

		// Keep object references
		var nid = this.indexRef.length;
		this.indexVal[eid].insert( propertyTable, nid );
		this.indexRef.push( object );

		// Keep ID on the object itself so we have a faster lookup,
		// and do it in a non-enumerable property so it doesn't pollute the objects.
		Object.defineProperty(
			object, "__iref__", {
				enumerable: false,
				value: nid,
			}
		);

	}
1100244
def bus_remove_match_action(self, rule, func, user_data, error = None) :
        ""
        rulekey = format_rule(rule)
        rule = unformat_rule(rule)
        self._match_actions[rulekey].actions.remove(_MatchActionEntry._Action(func, user_data))
        if len(self._match_actions[rulekey].actions) == 0 :
            self.bus_remove_match(rulekey, error) # shouldn’t fail!
            del self._match_actions[rulekey]
            if len(self._match_actions) == 0 :
                self.remove_filter(self._rule_action_match, None)
891496
function encodeEntities(value) {
    return value.replace(/&/g, '&amp;')
        .replace(SURROGATE_PAIR_REGEXP, function (match) {
        var /** @type {?} */ hi = match.charCodeAt(0);
        var /** @type {?} */ low = match.charCodeAt(1);
        return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
    })
        .replace(NON_ALPHANUMERIC_REGEXP, function (match) { return '&#' + match.charCodeAt(0) + ';'; })
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');
}
638227
public ENTITY findOne(Match... matches) {
        List<ENTITY> os = find(Arrays.asList(matches), null, 0, 1);
        if (os == null || os.size() == 0) {
            return null;
        }
        return os.get(0);
    }
838493
function _removeEmbed(state, id) {
  // get existing embed
  var embeds = state.embeds;
  var embed = embeds[id];
  var parent = embed.parent;
  var property = embed.property;

  // create reference to replace embed
  var subject = {'@id': id};

  // remove existing embed
  if(_isArray(parent)) {
    // replace subject with reference
    for(var i = 0; i < parent.length; ++i) {
      if(jsonld.compareValues(parent[i], subject)) {
        parent[i] = subject;
        break;
      }
    }
  }
  else {
    // replace subject with reference
    var useArray = _isArray(parent[property]);
    jsonld.removeValue(parent, property, subject, {propertyIsArray: useArray});
    jsonld.addValue(parent, property, subject, {propertyIsArray: useArray});
  }

  // recursively remove dependent dangling embeds
  var removeDependents = function(id) {
    // get embed keys as a separate array to enable deleting keys in map
    var ids = Object.keys(embeds);
    for(var i = 0; i < ids.length; ++i) {
      var next = ids[i];
      if(next in embeds && _isObject(embeds[next].parent) &&
        embeds[next].parent['@id'] === id) {
        delete embeds[next];
        removeDependents(next);
      }
    }
  };
  removeDependents(id);
}