Prepares a representation of the model that is easier accessible for our purposes.

@param model  The original model
@return The model representation
347555
private void prepareModel(DescriptorRepository model)
    {
        TreeMap result = new TreeMap();

        for (Iterator it = model.getDescriptorTable().values().iterator(); it.hasNext();)
        {
            ClassDescriptor classDesc = (ClassDescriptor)it.next();

            if (classDesc.getFullTableName() == null)
            {
                // not mapped to a database table
                continue;
            }

            String elementName        = getElementName(classDesc);
            Table  mappedTable        = getTableFor(elementName);
            Map    columnsMap         = getColumnsFor(elementName);
            Map    requiredAttributes = getRequiredAttributes(elementName);
            List   classDescs         = getClassDescriptorsMappingTo(elementName);

            if (mappedTable == null)
            {
                mappedTable = _schema.findTable(classDesc.getFullTableName());
                if (mappedTable == null)
                {
                    continue;
                }
                columnsMap         = new TreeMap();
                requiredAttributes = new HashMap();
                classDescs         = new ArrayList();
                _elementToTable.put(elementName, mappedTable);
                _elementToClassDescriptors.put(elementName, classDescs);
                _elementToColumnMap.put(elementName, columnsMap);
                _elementToRequiredAttributesMap.put(elementName, requiredAttributes);
            }
            classDescs.add(classDesc);
            extractAttributes(classDesc, mappedTable, columnsMap, requiredAttributes);
        }
        extractIndirectionTables(model, _schema);
    }
687349
public void init(Model model) {
	this.model = model;
	
	numLabels = model.taggerMaps.numLabels();
	
	Mi = new DoubleMatrix(numLabels, numLabels);
	Vi = new DoubleVector(numLabels);
	
	allocateMemory(100);
	
	// compute Mi once at initialization
	computeMi();
    }
1253407
function _ensureModel(model) {
      if (model instanceof this.model) {
        return model;
      } else if (typeof model === "object") {
        return new this.model(model);
      } else {
        return new this.model({ id: model });
      }
    }
1306315
public ClassFileBuilder prepare() throws SupportException {

        // Add a property to the reference for each primary key in the master
        List<StorableProperty> masterPkProps = new ArrayList<StorableProperty>
            (mMasterStorableInfo.getPrimaryKeyProperties().values());

        // Sort master primary keys, to ensure consistent behavior.
        Collections.sort(masterPkProps,
                         BeanComparator.forClass(StorableProperty.class).orderBy("name"));

        for (StorableProperty masterPkProp : masterPkProps) {
            // Some of them may have already been added as explicit
            // primary keys, to articulate sort direction.
            if (!mBuilder.hasProperty(masterPkProp.getName())) {
                addProperty(masterPkProp);
                // For non-unique indexes, *all* master pk properties are members of the
                // generated primary key, in order to support duplicates.
                if (!mIsUnique) {
                    mPrimaryKey.addProperty(masterPkProp.getName());
                    mExtraPkProps.add(masterPkProp.getName());
                }
            }
        }

        // Ensure that a version property exists in the index entry, if the
        // user storable had one.
        if (!mBuilder.isVersioned()) {
            StorableProperty versionProperty = mMasterStorableInfo.getVersionProperty();
            if (versionProperty != null) {
                addProperty(versionProperty);
            }
        }

        ClassFileBuilder cfg = mBuilder.prepare();
        addSpecialMethods(cfg.getClassFile());
        return cfg;
    }
187797
public Model filter(Model model) {
		if(model == null || model.getLevel() != BioPAXLevel.L2)
			return model; // nothing to do

		preparePep2PEIDMap(model);

		final Model newModel = factory.createModel();
		newModel.getNameSpacePrefixMap().putAll(model.getNameSpacePrefixMap());
		newModel.setXmlBase(model.getXmlBase());
		
		// facilitate the conversion
		normalize(model);
		
		// First, map classes (and only set ID) if possible (pre-processing)
		for(BioPAXElement bpe : model.getObjects()) {
			Level3Element l3element = mapClass(bpe);
			if(l3element != null) {
				newModel.add(l3element);
			} else {
				log.debug("Skipping " + bpe + " " + bpe.getModelInterface().getSimpleName());
			}
		}
		
		/* process each L2 element (mapping properties), 
		 * except for pEPs and oCVs that must be processed as values
		 * (anyway, we do not want dangling elements)
		 */
		for(BioPAXElement e : model.getObjects()) {
			if(e instanceof physicalEntityParticipant
				|| e instanceof openControlledVocabulary) {
				continue;
			}
			
			// map properties
			traverse((Level2Element) e, newModel);
		}

		log.info("Done: new L3 model contains " + newModel.getObjects().size() + " BioPAX individuals.");
		
		// fix new model (e.g., add PathwayStep's processes to the pathway components ;))
		normalize(newModel);
		
		return newModel;
	}
24326
@SuppressWarnings("unchecked")
	public static <K> IModel<K> model(K o)
    {
    	if(o instanceof ODocument) return (IModel<K>)new ODocumentModel((ODocument)o);
    	else if(o instanceof ODocumentWrapper) return (IModel<K>)new ODocumentWrapperModel<ODocumentWrapper>((ODocumentWrapper)o);
    	else if(o instanceof Serializable) return (IModel<K>)Model.of((Serializable)o);
    	else throw new WicketRuntimeException(ModelUtils.class.getSimpleName()+" can't work with non serializable objects: "+o);
    }
1238434
protected Service getServiceFrom(final Map<String, Object> model) {
        return (Service) model.get(CasViewConstants.MODEL_ATTRIBUTE_NAME_SERVICE);
    }
605670
@Override
  @GetMapping
  public String init(final Model model) {
    super.init(model);
    model.addAttribute("adminEmails", userService.getSuEmailAddresses());
    if (SecurityUtils.currentUserIsAuthenticated()) {
      User currentUser = userService.getUser(SecurityUtils.getCurrentUsername());
      if (currentUser != null) {
        model.addAttribute("userName", getFormattedName(currentUser));
        model.addAttribute("userEmail", currentUser.getEmail());
      }
    }
    model.addAttribute("isRecaptchaEnabled", appSettings.getRecaptchaIsEnabled());
    model.addAttribute("recaptchaPublicKey", appSettings.getRecaptchaPublicKey());
    return VIEW_FEEDBACK;
  }
79797
public static <T> TextField<T> newTextField(final String id, final IModel<T> model)
	{
		final TextField<T> textField = new TextField<>(id, model);
		textField.setOutputMarkupId(true);
		return textField;
	}
20588
static void setModelValue(final ModelNode model, final String value) {
        if (value != null) {
            model.set(value);
        }
    }
995618
public function process(Model $model)
    {
        $data = $model->getData();

        // Check if this is a possible callback.
        // We are not going to analyse this further, because modern systems
        // do not use these anymore.
        if (function_exists($data) === true) {
            $model->setIsCallback(true);
        }

        // Checking the encoding.
        $encoding = $this->pool->encodingService->mbDetectEncoding($data);
        if ($encoding === false) {
            // Looks like we have a mixed encoded string.
            // We need to tell the dev!
            $length = $this->pool->encodingService->mbStrLen($data);
            $strlen = 'broken encoding ' . $length;
            $model->addToJson(static::META_ENCODING, 'broken');
        } else {
            // Normal encoding, nothing special here.
            $length = $strlen = $this->pool->encodingService->mbStrLen($data, $encoding);
        }

        if ($length > 20) {
            // Getting mime type from the string.
            // With larger strings, there is a good chance that there is
            // something interesting in there.
            $model->addToJson(static::META_MIME_TYPE, $this->bufferInfo->buffer($data));
        }

        // Check, if we are handling large string, and if we need to use a
        // preview (which we call "extra").
        // We also need to check for linebreaks, because the preview can not
        // display those.
        if ($length > 50 || strstr($data, PHP_EOL) !== false) {
            $cut = $this->pool->encodingService->encodeString(
                $this->pool->encodingService->mbSubStr($data, 0, 50)
            ) . static::UNKNOWN_VALUE;

            $data = $this->pool->encodingService->encodeString($data);

            $model->setHasExtra(true)
                ->setNormal($cut)
                ->setData($data);
        } else {
            $model->setNormal($this->pool->encodingService->encodeString($data));
        }

        return $this->pool->render->renderSingleChild(
            $model->setType(static::TYPE_STRING . $strlen)
                ->addToJson(static::META_LENGTH, $length)
        );
    }
658734
protected void prepareValueModel(ValueModel valueModel) {
		if (valueModel instanceof BufferedValueModel) {
			((BufferedValueModel) valueModel).setCommitTrigger(commitTrigger);
		}

		// If the value model that we were built on is "dirty trackable" then we
		// need to monitor it for changes in its dirty state
		if (valueModel instanceof DirtyTrackingValueModel) {
			((DirtyTrackingValueModel) valueModel).addPropertyChangeListener(DIRTY_PROPERTY, childStateChangeHandler);
		}
	}
23297
public void assignModel(XLog log, String model) {
		if (model != null && model.trim().length() > 0) {
			XAttributeLiteral modelAttr = (XAttributeLiteral) ATTR_MODEL
					.clone();
			modelAttr.setValue(model.trim());
			log.getAttributes().put(KEY_MODEL, modelAttr);
		}
	}
270505
def mutable_model_prepared(signal, sender, definition, existing_model_class,
                           **kwargs):
    
    referenced_models = set()
    # Collect all model class the obsolete model class was referring to
    if existing_model_class:
        for field in existing_model_class._meta.local_fields:
            if isinstance(field, RelatedField):
                remote_field_model = get_remote_field_model(field)
                if not isinstance(remote_field_model, string_types):
                    referenced_models.add(remote_field_model)
    # Add sender as a dependency of all mutable models it refers to
    for field in sender._meta.local_fields:
        if isinstance(field, RelatedField):
            remote_field_model = get_remote_field_model(field)
            if not isinstance(remote_field_model, string_types):
                referenced_models.add(remote_field_model)
                if (issubclass(remote_field_model, MutableModel) and
                        remote_field_model._definition != sender._definition):
                    remote_field_model._dependencies.add(sender._definition)
    # Mark all model referring to this one as dependencies
    related_model_defs = ModelDefinition.objects.filter(
        Q(fielddefinitions__foreignkeydefinition__to=definition) |
        Q(fielddefinitions__manytomanyfielddefinition__to=definition)
    ).distinct()
    for model_def in related_model_defs:
        if model_def != definition:
            # Generate model class from definition and add it as a dependency
            sender._dependencies.add(model_def.model_class()._definition)
    # Clear the referenced models opts related cache
    for model_class in referenced_models:
        clear_opts_related_cache(model_class)
65059
public static AdvancedModelWrapper wrap(Object model) {
        if (!(isModel(model.getClass()))) {
            throw new IllegalArgumentException("The given object is no model");
        }
        return new AdvancedModelWrapper((OpenEngSBModel) model);
    }
143791
public Blacklist generateBlacklist(Model model)
	{
		Blacklist blacklist = new Blacklist();

		// populate the blacklist

		for (SmallMoleculeReference smr : model.getObjects(SmallMoleculeReference.class))
		{
			String name = smr.getDisplayName();
			if (name == null) continue;
			name = name.toLowerCase();

			if (knownNames.containsKey(name))
			{
				blacklist.addEntry(smr.getUri(), 1, knownNames.get(name));

				for (SimplePhysicalEntity spe : smr.getEntityReferenceOf())
				{
					blacklist.addEntry(spe.getUri(), 1, knownNames.get(name));
				}
			}
		}

		return blacklist;
	}
1233659
@Override
    public void preprocess(ServiceModel serviceModel) {

        if (renameShapes == null || renameShapes.isEmpty()) return;
        // sanity check
        for (Entry<String, String> entry : renameShapes.entrySet()) {

            String originalName = entry.getKey();
            String newName = entry.getValue();
            Shape originalShape = serviceModel.getShapes().get(originalName);

            if (originalShape == null) {
                throw new IllegalStateException(
                        String.format("Cannot find shape [%s] in the model when processing "
                                + "customization config renameShapes.%s", originalName, originalName));
            }
            if (serviceModel.getShapes().containsKey(newName)) {
                throw new IllegalStateException(
                        String.format("The shape [%s] for the new name is already in the model when processing "
                                + "customization config renameShapes.%s", newName, originalName));
            }
        }

        for (Entry<String, Shape> entry : serviceModel.getShapes().entrySet()) {
            String shapeName = entry.getKey();
            Shape shape = entry.getValue();

            preprocess_RenameMemberShapes(shapeName, shape);
        }
        for (Operation operation : serviceModel.getOperations().values()) {

            if (operation.getInput() != null) {
                preprocess_RenameInputShape(operation.getInput());
            }
            if (operation.getOutput() != null) {
                preprocess_RenameOutputShape(operation.getOutput());
            }
            if (operation.getErrors() != null) {
                for (ErrorMap error : operation.getErrors()) {
                    preprocess_RenameErrorShape(error);
                }
            }
        }
        for (Entry<String, String> entry : renameShapes.entrySet()) {
            String originalName = entry.getKey();
            String newName = entry.getValue();

            Shape shape = serviceModel.getShapes().remove(originalName);
            serviceModel.getShapes().put(newName, shape);
        }
    }