Example #1
0
void EntitiesEntity::getChildsStatement(const shared_ptr<IPortalDatabase> &database, const ObjectsTypes &types, const RangeUint32 &range, bool count, bool includeSystem, bool includeInvisible, shared_ptr<DbSqlSelect> &statement) const
{
	OS_LOCK(m_cs);

	// Nota: qui bisogna specificare sempre la tabella perch dall'esterno la select pu essere messa in join con altre tabelle

	shared_ptr<DbSqlSelect> select(OS_NEW DbSqlSelect(DBTABLES::SNAPSHOT_OBJECTS_TABLE));
	if(count)
		select->count = true;
	else
		select->fields.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::ENTITY, DBTABLES::SNAPSHOT_OBJECTS_TABLE));

	database->getPortal()->getSnapshotManager()->ensureChilds(database, getEntityID());
	select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::PARENT, DBTABLES::SNAPSHOT_OBJECTS_TABLE), Convert::toSQL(getEntityID()));

	// Genera il filtro sui tipi di figli
	StringList childsTypes;
	for(ObjectsTypes::const_iterator i = types.begin(); i != types.end(); ++i)
	{
		if((*i) != portalObjectTypeUnknown)
			childsTypes.push_back(Convert::toSQL(static_cast<uint32>(*i)));
	}

	// Se  stato specificato un filtro sul tipo di figli lo applica
	if(childsTypes.empty() == false)
	{
		select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::TYPE, DBTABLES::SNAPSHOT_OBJECTS_TABLE), childsTypes);
	}

	// Includi le sezioni di sistema (virtuali)?
	// Sono figlie della root, per cui la condizione ha senso solo in quel caso
	if(getEntityID() == ObjectsSystem::instance()->getRootID())
	{
		if(includeSystem == true)
		{
			// Salta la root stessa
			select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::ENTITY, DBTABLES::SNAPSHOT_OBJECTS_TABLE), Convert::toSQL(ObjectsSystem::instance()->getRootID()), DbSqlCondition::cfDifferent | DbSqlCondition::cfAnd);
		}
		else
		{
			// VERYURGENT: Le classi statement non hanno una "not in"... poco male, ma userebbe meglio l'indice.
			select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::INSERT_DATE, DBTABLES::SNAPSHOT_OBJECTS_TABLE), Convert::toSQL(DateTime::EMPTY), DbSqlCondition::cfDifferent | DbSqlCondition::cfAnd);
		}
	}

	if(includeInvisible == false)
		select->where.add(DbSqlField(DBTABLES::SNAPSHOT_OBJECTS::VISIBLE, DBTABLES::SNAPSHOT_OBJECTS_TABLE), Convert::toSQL(true));

	uint32 size = range.size();
	if(size != 0)
		select->limit.setCount(size);

	uint32 start = range.start();
	if(start != 0)
		select->limit.setOffset(start);

	statement = select;
}
Example #2
0
void EntitiesEntity::exportXML(shared_ptr<XMLPortalExporter> exporter)
{
	if(m_current == nullptr)
		return;

	m_current->exportXML(exporter);

	// "showable"  diverso dal "visible" esportato dalla corrente.
	// Un oggetto potrebbe essere invisibile per diversi motivi, ad esempio se il padre  invisibile.
	exporter->getRoot()->setAttributeBool(_S("showable"), m_visible);
	exporter->getRoot()->setAttributeUint32(_S("depth"), m_depth);
	exporter->getRoot()->setAttributeString(_S("section"), m_section.toUTF16());

	/* URGENT da testare
	// Se la sezione non  lui stesso
	if(m_section != getPrimaryID())
	{
		entity_ptr section = getLoggedUser()->getEntity(m_section);
		if(section != nullptr)
		{
			shared_ptr<XMLNode> nodeSection = exporter->getRoot()->addChild(_S("section"));
			shared_ptr<XMLPortalExporter> exporterSection(OS_NEW XMLExporter(nodeSection, getPage(), false));
			section->exportXML(exporterSection);
		}
	}
	*/

	//if(exporter->getMode() == XMLPortalExporter::emFull)
	{
		String id = getEntityID().toUTF16();
		String portal = exporter->getPortal()->getPortalID().toUTF16();
		String title = exporter->getRoot()->getAttributeString(_S("title"));
		if(title.empty())
			title = id;

		/*
		String omlCodeView;
		if(id != String::EMPTY)
			omlCodeView = String::format(_S("[iurl=\"osiris://|url|portals/view|id=%S&portal=%S\"]%S[/iurl]").c_str(), id.c_str(), portal.c_str(), title.c_str());
		else
			omlCodeView = String::format(_S("[iurl=\"osiris://|url|portals/view|portal=%S\"]%S[/iurl]").c_str(), portal.c_str(), title.c_str());
		exporter->getRoot()->setAttributeString(_S("oml_code2"),omlCodeView);
		*/

		OsirisLink link;
		link.setParam("type", _W("url"));
		link.setParam("portal", portal.to_wide());
		if(id != String::EMPTY)
			link.setParam("url",_W("/portals/view?id=") + id.to_wide());
		else
			link.setParam("url",_W("/portals/view"));

		exporter->getRoot()->setAttributeString(_S("oml_code"),_S("[iurl=\"") + link.generate() + _S("\"]") + title + _S("[/iurl]"));	
		
	}
}
Example #3
0
String CommentableObjectViewer::getCreatePostLink(const EntityID &quoted_object)
{
	ordered_map<std::wstring, std::wstring> params;
	params.set(OS_URL_PARAM_ACTION, conversions::to_wstring<uint32>(actCreatePost));

	if(quoted_object.empty() == false)
		params.set(OS_URL_PARAM_QUOTE, quoted_object.toWide());

	return getPortal()->getViewObjectLink(getEntityID(), params);
}
Example #4
0
shared_ptr<EntitiesEntity> EntitiesEntity::getParent(shared_ptr<IPortalDatabase> database) const
{
	// Se  la root, non ha padre.
	if(m_current == nullptr)
		return nullptr;

	if(getEntityID() == ObjectsSystem::instance()->getRootID())
		return nullptr;

	return database->getPortal()->getSnapshotManager()->getEntity(database, m_parent);
}
Example #5
0
ExtensionsComponentID ObjectsSection::getComponentID(shared_ptr<Portal> portal) const
{
	if(getEntityID() == ObjectsSystem::instance()->getRootID())
	{
		// Root component
		ExtensionsComponentID component = portal->getOptionsShared()->getLayoutComponent().to_ascii();
		return component;		
	}
	else
	{
		return component;
	}

	return ExtensionsComponentID::EMPTY;
}
Example #6
0
	bool IRenderNode::doTestVisible( Matrix4 const& trans )
	{
		return true;

		if ( mUseBoundSphere )
		{
			Camera* camera = getScene()->_getRenderCamera();
			if ( !camera->testVisible( trans , mBoundSphere ) )
			{
				DevMsg( 1 , "RenderNode isn't visible %d" , getEntityID() );
				return false;
			}
		}
		return true;
	}
Example #7
0
void ObjectsSection::exportXML(shared_ptr<XMLPortalExporter> exporter)
{
	RevisionableBase::exportXML(exporter);

	shared_ptr<XMLNode> node = exporter->getRoot();

	if(exporter->getMode() != XMLPortalExporter::emLite)
	{
		node->setAttributeString(DBTABLES::SECTIONS::TITLE, title);
		node->setAttributeString(DBTABLES::SECTIONS::DESCRIPTION, description);
	}

	if(exporter->getMode() == XMLPortalExporter::emData)
	{
		node->setAttributeString(DBTABLES::SECTIONS::COMPONENT, component->toUTF16());
		node->setAttributeString(DBTABLES::SECTIONS::DATA, data);
	}

	shared_ptr<IExtensionsComponent> component = getComponent(exporter->getPortal());
	if(component != nullptr)
		component->exportXML(getEntityID(), exporter);
}
Example #8
0
std::string EntitiesEntity::getEditLink(const shared_ptr<Portal> portal, const ordered_map<std::wstring, std::wstring> &params) const
{
	return portal->getEditObjectLink(getEntityID(), params);
}
Example #9
0
void ObjectsPollOption::exportXML(shared_ptr<XMLPortalExporter> exporter)
{
	RevisionableBase::exportXML(exporter);

	if(exporter->getMode() != XMLPortalExporter::emLite)
		exporter->getRoot()->setAttributeString(DBTABLES::POLLS_OPTIONS::TITLE, title);

	if(exporter->getWithStats())
	{
		shared_ptr<DataIStatistics> stats = exporter->getDatabase()->loadStatistics<DataPollOptionStats>(DBTABLES::POLLS_OPTIONS_STATS_TABLE, getEntityID().getString());
		if(stats != nullptr)
			stats->exportXML(exporter);
	}
}