/*
Creates a glyph for the complex member.

@param pe PhysicalEntity to represent as complex member
@param container Glyph for the complex shell
768590
private Glyph createComplexMember(PhysicalEntity pe, Glyph container) {
		Glyph g = createGlyphBasics(pe, false);
		container.getGlyph().add(g);

		// A PhysicalEntity may appear in many complexes -- we identify the member using its complex
		g.setId(g.getId() + "_" + ModelUtils.md5hex(container.getId()));
		glyphMap.put(g.getId(), g);

		Set<String> uris =  new HashSet<String>();
		uris.add(pe.getUri());
		sbgn2BPMap.put(g.getId(), uris);

		if("or".equalsIgnoreCase(g.getClazz())) {
			buildGeneric(pe, g, container);
		}

		return g;
	}
1048241
function createHitEntity (data) {
  var cylinder;
  var hitEntity;
  var torus;

  // Parent.
  hitEntity = document.createElement('a-entity');
  hitEntity.className = 'hitEntity';

  // Torus.
  torus = document.createElement('a-entity');
  torus.setAttribute('geometry', {
    primitive: 'torus',
    radius: data.hitCylinderRadius,
    radiusTubular: 0.01
  });
  torus.setAttribute('rotation', {x: 90, y: 0, z: 0});
  torus.setAttribute('material', {
    shader: 'flat',
    color: data.hitCylinderColor,
    side: 'double',
    depthTest: false
  });
  hitEntity.appendChild(torus);

  // Cylinder.
  cylinder = document.createElement('a-entity');
  cylinder.setAttribute('position', {x: 0, y: data.hitCylinderHeight / 2, z: 0});
  cylinder.setAttribute('geometry', {
    primitive: 'cylinder',
    segmentsHeight: 1,
    radius: data.hitCylinderRadius,
    height: data.hitCylinderHeight,
    openEnded: true
  });
  cylinder.setAttribute('material', {
    shader: 'flat',
    color: data.hitCylinderColor,
    side: 'double',
    src: cylinderTexture,
    transparent: true,
    depthTest: false
  });
  hitEntity.appendChild(cylinder);

  return hitEntity;
}
516072
private synchronized Map<Resourcepart, Presence> getOrCreatePresencesInternal(BareJid entity) {
        Map<Resourcepart, Presence> entityPresences = getPresencesInternal(entity);
        if (entityPresences == null) {
            if (contains(entity)) {
                entityPresences = new ConcurrentHashMap<>();
                presenceMap.put(entity, entityPresences);
            }
            else {
                LruCache<Resourcepart, Presence> nonRosterEntityPresences = new LruCache<>(32);
                nonRosterPresenceMap.put(entity, nonRosterEntityPresences);
                entityPresences = nonRosterEntityPresences;
            }
        }
        return entityPresences;
    }
1043283
public void eInit(XtendTypeDeclaration container, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlConstructor == null) {
			this.container = container;
			this.sarlConstructor = SarlFactory.eINSTANCE.createSarlConstructor();
			this.sarlConstructor.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
			container.getMembers().add(this.sarlConstructor);
		}
	}
661374
private Stream<Triple> memberRelations(final FedoraResource container) throws RepositoryException {
        final org.apache.jena.graph.Node memberRelation;

        if (container.hasProperty(LDP_HAS_MEMBER_RELATION)) {
            final Property property = getJcrNode(container).getProperty(LDP_HAS_MEMBER_RELATION);
            memberRelation = createURI(property.getString());
        } else if (container.hasType(LDP_BASIC_CONTAINER)) {
            memberRelation = LDP_MEMBER.asNode();
        } else {
            return empty();
        }

        final String insertedContainerProperty;

        if (container.hasType(LDP_INDIRECT_CONTAINER)) {
            if (container.hasProperty(LDP_INSERTED_CONTENT_RELATION)) {
                insertedContainerProperty = getJcrNode(container).getProperty(LDP_INSERTED_CONTENT_RELATION)
                    .getString();
            } else {
                return empty();
            }
        } else {
            insertedContainerProperty = MEMBER_SUBJECT.getURI();
        }

        return container.getChildren().flatMap(
            UncheckedFunction.uncheck(child -> {
                final org.apache.jena.graph.Node childSubject = uriFor(child.getDescribedResource());

                if (insertedContainerProperty.equals(MEMBER_SUBJECT.getURI())) {
                    return of(create(subject(), memberRelation, childSubject));
                }
                String insertedContentProperty = getPropertyNameFromPredicate(getJcrNode(resource()),
                        createResource(insertedContainerProperty), null);

                if (child.hasProperty(insertedContentProperty)) {
                    // do nothing, insertedContentProperty is good

                } else if (child.hasProperty(getReferencePropertyName(insertedContentProperty))) {
                    // The insertedContentProperty is a pseudo reference property
                    insertedContentProperty = getReferencePropertyName(insertedContentProperty);

                } else {
                    // No property found!
                    return empty();
                }

                return iteratorToStream(new PropertyValueIterator(
                        getJcrNode(child).getProperty(insertedContentProperty)))
                    .map(uncheck(v -> create(subject(), memberRelation,
                        new ValueConverter(getJcrNode(container).getSession(), translator()).convert(v).asNode())));
            }));
    }
1246015
public function renderEntityTemplate(EntityTemplate $template, Entity $entity, $path)
    {
        $template->setEntity($entity);

        $fileCollection = new FileCollection();

        $entityPath = $path . $template->getPath();

        $entityName = $template->getFilename();

        if ($entity->shouldRender($template->getTemplateName())) {
            $fileCollection->add(new File($entityPath, $entityName, $template->render()));
        } else {
            $fileCollection->add(new NoFile($entityPath, $entityName, sprintf('The entity \'%s\' is should not have a \'%s\'.', $entity->getFullyQualifiedName(), $template->getTemplateName())));
        }

        return $fileCollection;
    }
628247
private Glyph getCompartment(PhysicalEntity pe) {
		CellularLocationVocabulary cl = pe.getCellularLocation();
		if (cl != null && !cl.getTerm().isEmpty()) {
			String name = null;
			// get a cv term,
			// ignoring IDs (should not be there but happens)
			for(String term : cl.getTerm()) {
				term = term.toLowerCase();
				if(!term.matches("(go|so|mi|bto|cl|pato|mod):")) {
				 name = term;
				 break;
				}
			}
			return getCompartment(name);
		} else
			return null;
	}
13879
@Override
  public final <T> T retrieveEntityById(final Map<String, Object> pAddParam,
    final Class<T> pEntityClass, final Object pItsId) throws Exception {
    String query = evalSqlSelect(pAddParam, pEntityClass);
    @SuppressWarnings("unchecked")
    IFactorySimple<T> facEn = (IFactorySimple<T>) this.entitiesFactoriesFatory
      .lazyGet(pAddParam, pEntityClass);
    T entity = facEn.create(pAddParam);
    @SuppressWarnings("unchecked")
    IFillerObjectFields<T> filler = (IFillerObjectFields<T>)
      this.fctFillersObjectFields.lazyGet(pAddParam, pEntityClass);
    String idFldName = this.tablesMap
      .get(pEntityClass.getSimpleName()).getIdFieldName();
    filler.fill(pAddParam, entity, pItsId, idFldName);
    pAddParam.put("isOnlyId", Boolean.TRUE);
    ColumnsValues columnsValues = evalColumnsValues(pAddParam, entity);
    pAddParam.remove("isOnlyId");
    String whereId = evalWhereId(entity, columnsValues);
    return retrieveEntity(pAddParam, pEntityClass,
      query + " where " + whereId + ";\n");
  }
460106
public void eInit(XtendTypeDeclaration container, String name, IJvmTypeProvider context) {
		if (this.sarlEnumeration == null) {
			this.container = container;
			this.sarlEnumeration = SarlFactory.eINSTANCE.createSarlEnumeration();
			container.getMembers().add(this.sarlEnumeration);
			if (!Strings.isEmpty(name)) {
				this.sarlEnumeration.setName(name);
			}
		}
	}
1158109
protected void setContainer(final EntityContainer container) {
	if (!Objects.equals(this.container, container)) {
	    this.container = container;
	    if (!isAlive()) {
		return;
	    }
	    // Fix container based tags
	    if (container == null) {
		removeContainerTags();
	    } else {
		addContainerTags();
	    }
	}
    }
479465
private void DrawPrimitive( DrawEntity e, World w ) throws Exception
    {
        String oldEntityName = e.getType().getValue();
        String id = null;
        for (EntityEntry ent : net.minecraftforge.fml.common.registry.ForgeRegistries.ENTITIES)
        {
           if (ent.getName().equals(oldEntityName))
           {
               id = ent.getRegistryName().toString();
               break;
           }
        }
        if (id == null)
            return;

        NBTTagCompound nbttagcompound = new NBTTagCompound();
        nbttagcompound.setString("id", id);
        nbttagcompound.setBoolean("PersistenceRequired", true); // Don't let this entity despawn
        Entity entity;
        try
        {
            entity = EntityList.createEntityFromNBT(nbttagcompound, w);
            if (entity != null)
            {
                positionEntity(entity, e.getX().doubleValue(), e.getY().doubleValue(), e.getZ().doubleValue(), e.getYaw().floatValue(), e.getPitch().floatValue());
                entity.setVelocity(e.getXVel().doubleValue(), e.getYVel().doubleValue(), e.getZVel().doubleValue());
                // Set all the yaw values imaginable:
                if (entity instanceof EntityLivingBase)
                {
                    ((EntityLivingBase)entity).rotationYaw = e.getYaw().floatValue();
                    ((EntityLivingBase)entity).prevRotationYaw = e.getYaw().floatValue();
                    ((EntityLivingBase)entity).prevRotationYawHead = e.getYaw().floatValue();
                    ((EntityLivingBase)entity).rotationYawHead = e.getYaw().floatValue();
                    ((EntityLivingBase)entity).prevRenderYawOffset = e.getYaw().floatValue();
                    ((EntityLivingBase)entity).renderYawOffset = e.getYaw().floatValue();
                }
                w.getBlockState(entity.getPosition());  // Force-load the chunk if necessary, to ensure spawnEntity will work.
                if (!w.spawnEntity(entity))
                {
                    System.out.println("WARNING: Failed to spawn entity! Chunk not loaded?");
                }
            }
        }
        catch (RuntimeException runtimeexception)
        {
            // Cannot summon this entity.
            throw new Exception("Couldn't create entity type: " + e.getType().getValue());
        }
    }
626578
public void eInit(XtendTypeDeclaration container, String name, IJvmTypeProvider context) {
		if (this.sarlClass == null) {
			this.container = container;
			this.sarlClass = SarlFactory.eINSTANCE.createSarlClass();
			container.getMembers().add(this.sarlClass);
			if (!Strings.isEmpty(name)) {
				this.sarlClass.setName(name);
			}
		}
	}
361564
public static Optional<Entity> randomEntity(final EntityContainer container) {
	return randomEntity0(container.streamEntities(), container.getEntityCount());
    }
241103
private String getSMRID(PhysicalEntity pe)
	{
		if (pe instanceof SmallMolecule)
		{
			EntityReference er = ((SmallMolecule) pe).getEntityReference();
			if (er != null) return er.getUri();
		}
		return null;
	}
169793
function(doc, src) {
		var iframe = doc.createElement("iframe");
		var spirit = this.possess(iframe);
		spirit.css.add("gui-iframe");
		/*
		 * TODO: should be moved to src() method (but fails)!!!!!
		 */
		if (src) {
			if (gui.URL.external(src, doc)) {
				var url = new gui.URL(doc, src);
				spirit.xguest = url.protocol + "//" + url.host;
				//src = this.sign ( src, doc, spirit.$instanceid );
			}
		} else {
			src = this.SRC_DEFAULT;
		}
		iframe.src = src;
		return spirit;
	}
250686
public static int getEntityCountRecursively(final EntityContainer container) {
	final AtomicInteger result = new AtomicInteger();

	walkEntityTree(container, e -> {
	    result.incrementAndGet();
	    return EntityVisitResult.CONTINUE;
	});

	return result.get();
    }
415417
public void eInit(XtendTypeDeclaration container, String name, String modifier, IJvmTypeProvider context) {
		setTypeResolutionContext(context);
		if (this.sarlField == null) {
			this.container = container;
			this.sarlField = SarlFactory.eINSTANCE.createSarlField();
			this.sarlField.setAnnotationInfo(XtendFactory.eINSTANCE.createXtendMember());
			this.sarlField.setName(name);
			if (Strings.equal(modifier, "var")
				|| Strings.equal(modifier, "val")) {
				this.sarlField.getModifiers().add(modifier);
			} else {
				throw new IllegalStateException("Invalid modifier");
			}
			container.getMembers().add(this.sarlField);
		}
	}