Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6899f814

Von Christian Ehringfeld vor fast 10 Jahren hinzugefügt

  • ID 6899f8148c8f180eed8b58d2cf929e8135bfd017
  • Vorgänger 5f0abdb1
  • Nachfolger aa44e7d1

cleanup

Unterschiede anzeigen:

EntityManager.pro
QT += core
QT += sql
QT -= gui
TARGET = EntityManager
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
TARGET = CuteEntityManager
TEMPLATE = lib
DEFINES += CUTE_ENTITY_MANAGER_LIBRARY
HEADERS += \
src/base/entity.h \
src/base/entitymanager.h \
src/base/enums/persistencetype.h \
src/base/database.h \
src/base/enums/databasetype.h \
src/models/artikel.h \
src/base/enums/relationtype.h \
src/base/relation.h
src/entity.h \
src/entitymanager.h \
src/enums/persistencetype.h \
src/database.h \
src/enums/databasetype.h \
src/enums/relationtype.h \
src/relation.h
SOURCES += main.cpp \
SOURCES += \
src/base/entity.cpp \
src/base/entitymanager.cpp \
src/base/database.cpp \
src/models/artikel.cpp \
src/base/relation.cpp
src/entitymanager.cpp \
src/database.cpp \
src/relation.cpp
unix {
target.path = /usr/lib
INSTALLS += target
}
main.cpp
#include <QCoreApplication>
#include "src/base/entity.h"
#include "src/models/artikel.h"
#include "src/base/entitymanager.h"
#include <typeinfo>
#include <QDir>
#include <QDebug>
/**
* create,remove und merge funktionieren
*/
int main(int argc, char *argv[])
{
OpenTeacherTool::EntityManager *e = new OpenTeacherTool::EntityManager("QSQLITE",QDir::currentPath() + "/db.sqlite");
OpenTeacherTool::Artikel *b= new OpenTeacherTool::Artikel(30,"Peter123");
OpenTeacherTool::Entity *entity = b->getEntity();
qDebug() << "findByAttributes:" << e->findByAttributes(entity,true);
qDebug() << "create:" << e->create(entity);
qDebug() << "findAll:" << e->findAll(entity->getTablename());
entity->setAttributes(e->findByAttributes(entity,true).at(0));
qDebug() << "AttributeValues, Artikel:" << *b->getAttributeValues();
b->setName("Peter");
b->setPreis(20);
e->remove(entity);
qDebug() << "TypID:" << typeid(entity).name();
qDebug() << entity->getId();
qDebug() << "merge:" << e->merge(entity);
delete entity;
return 0;
}
src/database.cpp
/*
Database Class for managing a database connection
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "database.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
Database::Database(QSqlDatabase database) {
this->database = database;
src/database.h
/*
Header File Database
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASE_H
#define DATABASE_H
......
#include <QString>
#include <QDebug>
#include "enums/databasetype.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
class Database
{
src/entity.h
/*
Header File Entity
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MODEL_H
#define MODEL_H
......
#include <QDebug>
#include "enums/persistencetype.h"
#include "enums/databasetype.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
class Entity
{
src/entitymanager.cpp
/*
Entity Manager for crud operations of entities
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "entitymanager.h"
......
* Fehlermeldungen erstellen am besten eine Exception Klasse diesbzgl. erstellen
*/
namespace OpenTeacherTool {
namespace CuteEntityManager {
QStringList EntityManager::connectionNames = QStringList();
src/entitymanager.h
/*
Header File Entity Manager
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ENTITYMANAGER_H
#define ENTITYMANAGER_H
......
#include "entity.h"
#include "database.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
class EntityManager
{
src/enums/databasetype.h
/*
Enum DatabaseType
Copyright (C) 2013 Christian Ehringfeld <c.ehringfeld@t-online.de>
This file is part of OpenTeacherTool.
OpenTeacherTool is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenTeacherTool is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenTeacherTool. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DATABASETYPE_H
#define DATABASETYPE_H
namespace OpenTeacherTool {
namespace CuteEntityManager {
enum DatabaseType {
SQLITE=0,
PGSQL=1,
src/enums/persistencetype.h
/*
OpenTeacherTool, a platform independent tool for schoolteacher
Copyright (C) 2013 Yves Bodenheimer, Christian Ehringfeld, David Mock
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PERSISTENCETYPE_H
#define PERSISTENCETYPE_H
......
#include <QMap>
#include <QString>
namespace OpenTeacherTool {
namespace CuteEntityManager {
enum PersistenceType {
LOCAL=0,
XML=1,
src/enums/relationtype.h
/*
OpenTeacherTool, a platform independent tool for schoolteacher
Copyright (C) 2013 Yves Bodenheimer, Christian Ehringfeld, David Mock
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RELATIONTYPE_H
#define RELATIONTYPE_H
namespace OpenTeacherTool{
namespace CuteEntityManager{
enum Relationtype {
ONETOONE=0,
src/relation.cpp
/*
OpenTeacherTool, a platform independent tool for schoolteacher
Copyright (C) 2013 Yves Bodenheimer, Christian Ehringfeld, David Mock
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "relation.h"
namespace OpenTeacherTool {
namespace CuteEntityManager {
Relation::Relation()
{
src/relation.h
/*
OpenTeacherTool, a platform independent tool for schoolteacher
Copyright (C) 2013 Yves Bodenheimer, Christian Ehringfeld, David Mock
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RELATION_H
#define RELATION_H
#include "entity.h"
#include "src/base/enums/relationtype.h"
namespace OpenTeacherTool {
#include "src/enums/relationtype.h"
namespace CuteEntityManager {
class Relation
{
test/EntityManager.pro
#-------------------------------------------------
#
# Project created by QtCreator 2013-08-01T15:03:24
#
#-------------------------------------------------
QT += core
QT += sql
QT -= gui
TARGET = EntityManager
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
HEADERS += \
src/entity.h \
src/entitymanager.h \
src/enums/persistencetype.h \
src/database.h \
src/enums/databasetype.h \
src/enums/relationtype.h \
src/relation.h
SOURCES += \
src/base/entity.cpp \
src/entitymanager.cpp \
src/database.cpp \
src/relation.cpp
test/main.cpp
#include <QCoreApplication>
#include "src/entitymanager.h"
#include <typeinfo>
#include <QDir>
#include <QDebug>
/**
* create,remove und merge funktionieren
*/
int main(int argc, char *argv[])
{
OpenTeacherTool::EntityManager *e = new OpenTeacherTool::EntityManager("QSQLITE",QDir::currentPath() + "/db.sqlite");
OpenTeacherTool::Artikel *b= new OpenTeacherTool::Artikel(30,"Peter123");
OpenTeacherTool::Entity *entity = b->getEntity();
qDebug() << "findByAttributes:" << e->findByAttributes(entity,true);
qDebug() << "create:" << e->create(entity);
qDebug() << "findAll:" << e->findAll(entity->getTablename());
entity->setAttributes(e->findByAttributes(entity,true).at(0));
qDebug() << "AttributeValues, Artikel:" << *b->getAttributeValues();
b->setName("Peter");
b->setPreis(20);
e->remove(entity);
qDebug() << "TypID:" << typeid(entity).name();
qDebug() << entity->getId();
qDebug() << "merge:" << e->merge(entity);
delete entity;
return 0;
}

Auch abrufbar als: Unified diff