Пример #1
0
qReal::IdList Repository::elementsByPropertyContent(const QString &propertyValue, bool sensitivity
		, bool regExpression) const
{
	const Qt::CaseSensitivity caseSensitivity = sensitivity ? Qt::CaseSensitive : Qt::CaseInsensitive;

	const QRegExp regExp(propertyValue, caseSensitivity);
	IdList result;

	for (Object * const element : mObjects.values()) {
		QMapIterator<QString, QVariant> iterator = element->propertiesIterator();
		if (regExpression) {
			while (iterator.hasNext()) {
				if (iterator.next().value().toString().contains(regExp)) {
					result.append(mObjects.key(element));
					break;
				}
			}
		} else {
			while (iterator.hasNext()) {
				if (iterator.next().value().toString().contains(propertyValue, caseSensitivity)) {
					result.append(mObjects.key(element));
					break;
				}
			}
		}
	}

	return result;
}
Пример #2
0
IdList RefactoringApplier::elementsFromBlock(QString const &blockType) const
{
	IdList list;
	IdList resultList;
	IdList const refactoringElements = mRefactoringRepoApi->children(Id::rootId());
	foreach (Id const &refactoringElement, refactoringElements) {
		if (mRefactoringRepoApi->isGraphicalElement(refactoringElement)) {
			if (refactoringElement.element() == "RefactoringDiagramNode") {
				list = mRefactoringRepoApi->children(refactoringElement);
				foreach (Id const &id, list) {
					if (id.element() == blockType) {
						resultList.append(mRefactoringRepoApi->children(id));
						break;
					}
				}
				foreach (Id const &id, list) {
					if (id.element() == "Link" && resultList.contains(toInRule(id))
							&& resultList.contains(fromInRule(id)))
					{
						resultList.append(id);
					}
				}
			}
		}
	}
Пример #3
0
IdList Repository::findElementsByName(const QString &name, bool sensitivity, bool regExpression) const
{
	const Qt::CaseSensitivity caseSensitivity = sensitivity ? Qt::CaseSensitive : Qt::CaseInsensitive;

	const QRegExp regExp(name, caseSensitivity);
	IdList result;

	if (regExpression){
		for (Object * const element : mObjects.values()) {
			if (element->property("name").toString().contains(regExp)
					&& !isLogicalId(mObjects.key(element))) {
				result.append(mObjects.key(element));
			}
		}
	} else {
		for (Object * const element : mObjects.values()) {
			if (element->property("name").toString().contains(name, caseSensitivity)
					&& !isLogicalId(mObjects.key(element))) {
				result.append(mObjects.key(element));
			}
		}
	}

	return result;
}
/** @cond doxygenLibsbmlInternal */
IdList*
SBMLLevelVersionConverter::collectSpeciesReferenceIds()
{
  IdList* srids = new IdList();

  for (unsigned int i = 0; i < mDocument->getModel()->getNumReactions(); i++)
  {
    Reaction *r = mDocument->getModel()->getReaction(i);
    for (unsigned int j = 0; j < r->getNumReactants(); j++)
    {
      if (r->getReactant(j)->isSetId())
      {
        srids->append(r->getReactant(j)->getId());
      }
    }
    for (unsigned int j = 0; j < r->getNumProducts(); j++)
    {
      if (r->getProduct(j)->isSetId())
      {
        srids->append(r->getProduct(j)->getId());
      }
    }
  }

  return srids;
}
Пример #5
0
void MultipleRemoveCommand::setItemsToDelete(IdList &itemsToDelete)
{
	IdList itemsToUpdate;

	addEdgesToBeDeleted(itemsToDelete);
	// QGraphicsScene::selectedItems() returns items in no particular order,
	// so we should handle parent-child relationships manually
	while (!itemsToDelete.isEmpty()) {
		const Id currentItem = itemsToDelete.at(0);
		const IdList children = mGraphicalApi.children(currentItem);
		foreach (const Id &child, children) {
			itemsToDelete.removeAll(child);
			// Child remove commands will be added in currentItem delete command
		}

		const bool isEdge = !mLogicalApi.editorManagerInterface().isGraphicalElementNode(currentItem);
		if (isEdge) {
			const Id src = mGraphicalApi.from(currentItem);
			if (src != Id() && !itemsToUpdate.contains(src)) {
				itemsToUpdate.append(src);
			}
			const Id dst = mGraphicalApi.to(currentItem);
			if (dst != Id() && !itemsToUpdate.contains(dst)) {
				itemsToUpdate.append(dst);
			}

			insertPreAction(graphicalDeleteCommand(currentItem), 0);
		} else {
			addPreAction(graphicalDeleteCommand(currentItem));
		}

		itemsToDelete.removeAll(currentItem);
	}
Пример #6
0
IdList Repository::idsOfAllChildrenOf(Id id) const
{
	IdList result;
	result.clear();
	result.append(id);
	IdList list = mObjects[id]->children();
	for (const Id &childId : list) {
		result.append(idsOfAllChildrenOf(childId));
	}

	return result;
}
IdList GraphicalModelAssistApi::graphicalIdsByLogicalId(Id const &logicalId) const
{
	IdList result;
	QList<QPersistentModelIndex> indexes = mGraphicalModel.indexesWithLogicalId(logicalId);
	foreach (QPersistentModelIndex index, indexes) {
		result.append(idByIndex(index));
	}
Пример #8
0
QString JavaHandler::generateToJava(QString const &pathToDir)
{
	mErrorText = "";
	this->pathToDir = pathToDir;

	Id repoId = ROOT_ID;

	if (checkTheModel()) {
		IdList allDiagrams = mApi.children(repoId);
		IdList classDiagrams;

		//separate just class diagrams, because they are the main diagrams, others are connected
		foreach (Id const aDiagram, allDiagrams) {
			if (objectType(aDiagram) == "ClassDiagram_ClassDiagramNode") {
				classDiagrams.append(aDiagram);
			}
			if (objectType(aDiagram) == "ActivityDiagram_ActivityDiagramNode") {
				//If there is no connected Class Methods it won't be serialized
				IdList incomingConnections = mApi.incomingConnections(aDiagram);
				if (incomingConnections.isEmpty()) {
					addError("Unable to serialize object " + objectType(aDiagram) + " with type: " + aDiagram.toString() + ". It is not connected to some class method.");
				}
			}
		}

		foreach (Id const classDiagram, classDiagrams) {
			serializeChildren(classDiagram);
		}
	}
Пример #9
0
IdList RefactoringApplier::applyElementsTo()
{
	IdList result;
	for (int i = 0; i < mApply->size(); ++i) {
		result.append(mApply->at(i).second);
	}
	return result;
}
Пример #10
0
IdList GraphicalModelAssistApi::graphicalIdsByLogicalId(const Id &logicalId) const
{
	IdList result;
	QList<QPersistentModelIndex> indexes = mGraphicalModel.indexesWithLogicalId(logicalId);
	for (const QPersistentModelIndex &index : indexes) {
		result.append(idByIndex(index));
	}

	return result;
}
Пример #11
0
IdList VisualInterpreterUnit::allRules() const
{
	IdList const elements = elementsFromActiveDiagram();
	IdList result;
	foreach (Id const &element, elements) {
		if (element.element() == "SemanticsRule") {
			result.append(element);
		}
	}
	return result;
}
Пример #12
0
Id RefactoringApplier::subprogramElementId() const
{
	IdList result;
	IdList const after = elementsFromAfterBlock();
	for (Id const &id : after) {
		if (mRefactoringRepoApi->isGraphicalElement(id)
				&& (isNodeInRule(id)))
			result.append(id);
	}
	if (result.size() == 1)
		return result.first();
	return Id::rootId();
}
Пример #13
0
IdList LogicalModelAssistApi::diagramsFromList(IdList const &list) const
{
	// TODO: diagrams are kinda special, so we need the editor to be able to
	// tell us whether this particular element is a diagram or not
	IdList result;
	foreach (Id type, list) {
		if (type.element().split("_").back().contains("Diagram", Qt::CaseInsensitive)) {
			if (!result.contains(type))
				result.append(type);
		}
	}
	return result;
}
Пример #14
0
qReal::IdList Repository::elementsByProperty(const QString &property, bool sensitivity
		, bool regExpression) const
{
	IdList result;

	for (Object *element : mObjects.values()) {
		if ((element->hasProperty(property, sensitivity, regExpression))
				&& (!isLogicalId(mObjects.key(element)))) {
			result.append(mObjects.key(element));
		}
	}

	return result;
}
void 
FunctionDefinitionRecursion::determineCycles(const Model& m)
{
  IdIter it;
  IdRange range;
  IdList variables;
  IdMap logged;
  std::string id;
  variables.clear();

  /* create a list of variables that are cycles ie (x, x) */
  for (it = mIdMap.begin(); it != mIdMap.end(); it++)
  {
    if ((*it).first == (*it).second)
    {
      id = (*it).first;
      if (!variables.contains(id))
      {
        variables.append(id);
      }
    }
  }

  /* loop thru other dependencies for each; if the dependent is also
   * in the list then this is the cycle
   * keep a record of logged dependencies to avoid logging twice
   */
   
  for (unsigned int n = 0; n < variables.size(); n++)
  {
    id = variables.at((int)n);
    range = mIdMap.equal_range(id);
    for (it = range.first; it != range.second; it++)
    {
      if (((*it).second != id)
        && (variables.contains((*it).second))
        && !alreadyExistsInMap(logged, 
                   pair<const std::string, std::string>(id, (*it).second))
        && !alreadyExistsInMap(logged, 
                   pair<const std::string, std::string>((*it).second, id)))
      {
        logCycle(m.getFunctionDefinition(id), m.getFunctionDefinition((*it).second));
        logged.insert(pair<const std::string, std::string>(id, (*it).second));
      }
    }
  }
}
Пример #16
0
IdList BaseGraphTransformationUnit::elementsFromActiveDiagram() const
{
	unsigned const validIdSize = 4;
	Id const activeDiagram = mInterpretersInterface.activeDiagram();
	if (activeDiagram.idSize() < validIdSize) {
		mInterpretersInterface.errorReporter()->addError(tr("no current diagram"));
		return IdList();
	}
	IdList const activeDiagramElements = children(activeDiagram);
	IdList activeDiagramGraphicalElements;
	foreach (Id const &id, activeDiagramElements) {
		if (mGraphicalModelApi.isGraphicalId(id)) {
			activeDiagramGraphicalElements.append(id);
		}
	}
	return activeDiagramGraphicalElements;
}
bool
containsId(const ASTNode* ast, std::string id)
{
  bool present = false;
  List* variables = ast->getListOfNodes(ASTNode_isName);
  IdList vars;
  for (unsigned int i = 0; i < variables->getSize(); i++)
  {
    ASTNode* node = static_cast<ASTNode*>(variables->get(i));
    string   name = node->getName() ? node->getName() : "";
    vars.append(name);
  }
  if (vars.contains(id))
  {
    present = true;
  }
  delete variables;

  return present;
}
Пример #18
0
bool RulesChecker::makeDetour(Id const &currentNode, IdList &usedNodes)
{
	if (usedNodes.contains(currentNode)) {
		return false; // cannot learn some more here
	}

	if (!mDiagramElements.contains(currentNode)) {
		return true;  // we already have made detour of forward nodes
	}

	mDiagramElements.removeOne(currentNode);
	usedNodes.append(currentNode);

	if (currentNode.element() != "MessageFlow" && isLink(currentNode)) {
		Id const destinationNode = mGRepoApi->to(currentNode);
		if (destinationNode == Id::rootId()) {
			postError(noEndNode, currentNode); // we've already put info that link is incorrect
			return true; // done end-job for link(50%)
		}
		return makeDetour(destinationNode, usedNodes);
	}

	if (isEndNode(currentNode)) {
		return true; // we found real end-node
	}

	IdList frontNodes = outgoingSequenceFlow(currentNode);

	if (frontNodes.isEmpty()) {
		postError(noEndNode, currentNode);
		return true; // done end-job for nodes (now 100%)
	}

	bool foundFinalNode = false; // to catch that we have found end-node anywhere in path
	foreach (Id const &node, frontNodes) {
		if (makeDetour(node, usedNodes)) {
			foundFinalNode = true;
		}
	}
	return foundFinalNode;
}
/*
  * Checks that the units of the result of the assignment rule
  * are consistent with variable being assigned
  *
  * @return @c true if units are consistent, false otherwise.
  */
void
KineticLawUnitsCheck::check_ (const Model& m, const Model&)
{
  unsigned int n, p;
  IdList matched;
  IdList unmatched;
  const UnitDefinition *ud1=NULL, *ud2=NULL;

  if (m.getLevel() < 3)
    return;

  if (m.getNumReactions() < 2)
    return;

  /* log first KL with units declared*/ 
  for (n = 0; n < m.getNumReactions(); n++)
  {
    if (m.getReaction(n)->isSetKineticLaw())
    {
      if (m.getReaction(n)->getKineticLaw()->isSetMath())
      {
        if (!(m.getReaction(n)->getKineticLaw()->containsUndeclaredUnits()))
        {
          ud1 = m.getReaction(n)->getKineticLaw()->getDerivedUnitDefinition();
          matched.append(m.getReaction(n)->getId());
          break;
        }
      }
    }
  }

  /* loop thru remaining kl - if they are fully declared check that they match
   * and add to matched or unmatch as appropriate
   */
  for (p = n+1; p < m.getNumReactions(); p++)
  {
    if (m.getReaction(p)->isSetKineticLaw())
    {
      if (m.getReaction(p)->getKineticLaw()->isSetMath())
      {
        if (!(m.getReaction(p)->getKineticLaw()->containsUndeclaredUnits()))
        {
          ud2 = m.getReaction(p)->getKineticLaw()->getDerivedUnitDefinition();
          if (UnitDefinition::areEquivalent(ud1, ud2))
          {
            matched.append(m.getReaction(p)->getId());
          }
          else
          {
            unmatched.append(m.getReaction(p)->getId());
          }
        }
      }
    }
  }

  /* see if we have any unmatched */
  for (n = 0; n < unmatched.size(); n++)
  {

    logKLConflict(*(m.getReaction(unmatched.at((int)n))->getKineticLaw()->getMath()),
                  *(static_cast<const SBase *>(m.getReaction(unmatched.at((int)n)))));
  }

}
Пример #20
0
/*!
 * \brief Buddy::update
 * \param fields - some fields need to update.
 * api reference \link http://vk.com/developers.php?oid=-1&p=users.get
 */
void Buddy::update(const QStringList &fields)
{
    IdList ids;
    ids.append(id());
    d_func()->client->roster()->update(ids, fields);
}
Пример #21
0
/* in L1 and L2 there were built in values for key units
 * such as 'volume', 'length', 'area', 'substance' and 'time'
 * In L3 these have been removed - thus if a model uses one of these
 * it needs a unitDefinition to define it
 */
void
Model::addDefinitionsForDefaultUnits()
{
  /* create a list of unit values */
  IdList unitsUsed;
  unsigned int n;
  bool implicitVolume = false;
  bool implicitArea = false;
  bool implicitLength = false;
  bool implicitSubstance = false;

  for (n = 0; n < getNumCompartments(); n++)
  {
    if (getCompartment(n)->isSetUnits())
    {
      unitsUsed.append(getCompartment(n)->getUnits());
    }
    else
    {
      if (getCompartment(n)->getSpatialDimensions() == 3)
      {
        implicitVolume = true;
        getCompartment(n)->setUnits("volume");
      }
      else if (getCompartment(n)->getSpatialDimensions() == 2)
      {
        implicitArea = true;
        getCompartment(n)->setUnits("area");
      }
      else if (getCompartment(n)->getSpatialDimensions() == 1)
      {
        implicitLength = true;
        getCompartment(n)->setUnits("length");
      }
    }
  }

  for (n = 0; n < getNumSpecies(); n++)
  {
    if (getSpecies(n)->isSetSubstanceUnits())
    {
      unitsUsed.append(getSpecies(n)->getSubstanceUnits());
    }
    else
    {
      implicitSubstance = true;
      getSpecies(n)->setSubstanceUnits("substance");
    }
 
    if (getSpecies(n)->isSetSpatialSizeUnits())
      unitsUsed.append(getSpecies(n)->getSpatialSizeUnits());
  }

  for (n = 0; n < getNumParameters(); n++)
  {
    if (getParameter(n)->isSetUnits())
      unitsUsed.append(getParameter(n)->getUnits());
  }

  if (getUnitDefinition("volume") == NULL)
  {
    if (unitsUsed.contains("volume") || implicitVolume)
    {
      UnitDefinition * ud = createUnitDefinition();
      ud->setId("volume");
      Unit * u = ud->createUnit();
      u->setKind(UnitKind_forName("litre"));
      u->setScale(0);
      u->setExponent(1.0);
      u->setMultiplier(1.0);
      setVolumeUnits("volume");
    }
    else
    {
      setVolumeUnits("litre");
    }
  }
  else
  {
    setVolumeUnits("volume");
  }


  if (getUnitDefinition("substance") == NULL)
  {
    if (unitsUsed.contains("substance") || implicitSubstance)
    {
      UnitDefinition * ud = createUnitDefinition();
      ud->setId("substance");
      Unit * u = ud->createUnit();
      u->setKind(UnitKind_forName("mole"));
      u->setScale(0);
      u->setExponent(1.0);
      u->setMultiplier(1.0);
      setSubstanceUnits("substance");
      setExtentUnits("substance");
    }
    else
    {
      setSubstanceUnits("mole");
      setExtentUnits("mole");
    }
  }
  else
  {
    setSubstanceUnits("substance");
    setExtentUnits("substance");
  }

  if (getUnitDefinition("area") == NULL)
  {
    UnitDefinition * ud = createUnitDefinition();
    ud->setId("area");
    Unit * u = ud->createUnit();
    u->setKind(UnitKind_forName("metre"));
    u->setScale(0);
    u->setExponent(2.0);
    u->setMultiplier(1.0);
    setAreaUnits("area");
  }
  else
  {
    setAreaUnits("area");
  }

  if (getUnitDefinition("length") == NULL)
  {
    if (unitsUsed.contains("length") || implicitLength)
    {
      UnitDefinition * ud = createUnitDefinition();
      ud->setId("length");
      Unit * u = ud->createUnit();
      u->setKind(UnitKind_forName("metre"));
      u->setScale(0);
      u->setExponent(1.0);
      u->setMultiplier(1.0);
      setLengthUnits("length");
    }
    else
    {
      setLengthUnits("metre");
    }
  }
  else
  {
    setLengthUnits("length");
  }

  if (getUnitDefinition("time") == NULL)
  {
    setTimeUnits("second");
  }
  else
  {
    setTimeUnits("time");
  }

}
Пример #22
0
IdList EditorManager::editors() const
{
	IdList editors;
	foreach (QString const &editor, mPluginsLoaded) {
		editors.append(Id(editor));
	}