Herunterladen als
root/tests/models.cpp @ 9c269b1f
f2bd88b8 | Christian Ehringfeld | #include "models.h"
|
|
Person::Person(QObject *parent): Entity(parent) {
|
|||
}
|
|||
10cc871a | Christian Ehringfeld | ||
f2bd88b8 | Christian Ehringfeld | Person::Person(QString firstName, QString familyName, Gender gender,
|
|
21826301 | Christian Ehringfeld | QString nickName,
|
|
f2bd88b8 | Christian Ehringfeld | QDate birthday, QObject *parent): Entity(parent) {
|
|
setFirstName(firstName);
|
|||
setFamilyName(familyName);
|
|||
setNickName(nickName);
|
|||
setBirthday(birthday);
|
|||
setGender(gender);
|
|||
}
|
|||
const QHash<QString, CuteEntityManager::Relation> Person::getRelations() const {
|
|||
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
|||
hash.insert("groups", CuteEntityManager::Relation("groups",
|
|||
f8b8663b | Christian Ehringfeld | RelationType::MANY_TO_MANY));
|
|
f2bd88b8 | Christian Ehringfeld | hash.insert("maintainedGroups", CuteEntityManager::Relation("maintainedGroups",
|
|
RelationType::ONE_TO_MANY,
|
|||
QString("leader")));
|
|||
return hash;
|
|||
}
|
|||
QString Person::fullName(NameOrder nameOrder) const {
|
|||
QString name = QString();
|
|||
if (nameOrder == NameOrder::FAMILY_FIRST_NAME_ORDER) {
|
|||
name += this->getFamilyName();
|
|||
name += ", ";
|
|||
name += this->getFirstName();
|
|||
} else {
|
|||
name += this->getFirstName();
|
|||
name += " ";
|
|||
name += this->getFamilyName();
|
|||
}
|
|||
return name;
|
|||
}
|
|||
QString Person::getFirstName() const {
|
|||
return firstName;
|
|||
}
|
|||
void Person::setFirstName(const QString &value) {
|
|||
firstName = value;
|
|||
}
|
|||
QString Person::getFamilyName() const {
|
|||
return familyName;
|
|||
}
|
|||
void Person::setFamilyName(const QString &value) {
|
|||
familyName = value;
|
|||
}
|
|||
QString Person::getNickName() const {
|
|||
return nickName;
|
|||
}
|
|||
void Person::setNickName(const QString &value) {
|
|||
nickName = value;
|
|||
}
|
|||
QDate Person::getBirthday() const {
|
|||
return birthday;
|
|||
}
|
|||
void Person::setBirthday(const QDate &value) {
|
|||
birthday = value;
|
|||
}
|
|||
Person::Gender Person::getGender() const {
|
|||
return gender;
|
|||
}
|
|||
void Person::setGender(const Gender &value) {
|
|||
gender = value;
|
|||
}
|
|||
e7cfc35a | Christian Ehringfeld | QList<QSharedPointer<Group>> Person::getGroups() const {
|
|
f2bd88b8 | Christian Ehringfeld | return groups;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Person::setGroups(const QList<QSharedPointer<Group>> &value) {
|
|
f2bd88b8 | Christian Ehringfeld | groups = value;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | QList<QSharedPointer<Group>> Person::getMaintainedGroups() const {
|
|
f2bd88b8 | Christian Ehringfeld | return maintainedGroups;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Person::setMaintainedGroups(const QList<QSharedPointer<Group>> &value) {
|
|
f2bd88b8 | Christian Ehringfeld | maintainedGroups = value;
|
|
}
|
|||
Group::Group() : Entity() {
|
|||
}
|
|||
const QHash<QString, CuteEntityManager::Relation> Group::getRelations() const {
|
|||
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
|||
hash.insert("persons", CuteEntityManager::Relation("persons",
|
|||
f8b8663b | Christian Ehringfeld | RelationType::MANY_TO_MANY, QString("groups")));
|
|
f2bd88b8 | Christian Ehringfeld | hash.insert("leader", CuteEntityManager::Relation("leader",
|
|
RelationType::MANY_TO_ONE));
|
|||
return hash;
|
|||
}
|
|||
QString Group::getName() const {
|
|||
return name;
|
|||
}
|
|||
void Group::setName(const QString &value) {
|
|||
name = value;
|
|||
}
|
|||
QSharedPointer<Person> Group::getLeader() const {
|
|||
10cc871a | Christian Ehringfeld | return leader;
|
|
f2bd88b8 | Christian Ehringfeld | }
|
|
void Group::setLeader(const QSharedPointer<Person> &value) {
|
|||
10cc871a | Christian Ehringfeld | leader = value;
|
|
f2bd88b8 | Christian Ehringfeld | }
|
|
10cc871a | Christian Ehringfeld | ||
e7cfc35a | Christian Ehringfeld | QList<QSharedPointer<Person>> Group::getPersons() const {
|
|
f2bd88b8 | Christian Ehringfeld | return persons;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Group::addPerson(const QSharedPointer<Person> &value) {
|
|
this->persons.append(value);
|
|||
}
|
|||
void Group::setPersons(const QList<QSharedPointer<Person>> &value) {
|
|||
f2bd88b8 | Christian Ehringfeld | persons = value;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Group::removePerson(const QSharedPointer<Person> &value) {
|
|
this->persons.removeOne(value);
|
|||
}
|
|||
f2bd88b8 | Christian Ehringfeld | ||
e7cfc35a | Christian Ehringfeld | double Article::getPrice() const {
|
|
9e2d71d6 | Christian Ehringfeld | return price;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Article::setPrice(double value) {
|
|
9e2d71d6 | Christian Ehringfeld | price = value;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | QString Article::getName() const {
|
|
9e2d71d6 | Christian Ehringfeld | return name;
|
|
}
|
|||
e7cfc35a | Christian Ehringfeld | void Article::setName(const QString &value) {
|
|
9e2d71d6 | Christian Ehringfeld | name = value;
|
|
}
|
|||
f2bd88b8 | Christian Ehringfeld | ||
9e2d71d6 | Christian Ehringfeld | Article::~Article() {
|
|
}
|
|||
f2bd88b8 | Christian Ehringfeld | ||
9e2d71d6 | Christian Ehringfeld | Article::Article() {
|
|
this->price = 0.0;
|
|||
}
|
|||
Article::Article(double price, QString name) {
|
|||
this->price = price;
|
|||
this->name = name;
|
|||
}
|
|||
e7cfc35a | Christian Ehringfeld | ||
QList<CuteEntityManager::ValidationRule> Person::validationRules() const {
|
|||
QList<CuteEntityManager::ValidationRule> rules =
|
|||
QList<CuteEntityManager::ValidationRule>();
|
|||
rules.append(ValidationRule("length", {"firstName", "familyName"}, "min", 2));
|
|||
QList<Param> params = {Param("past"), Param("min", QDate(1970, 1, 1))};
|
|||
rules.append(ValidationRule("date", "birthday", params));
|
|||
return rules;
|
|||
}
|
|||
f8b8663b | Christian Ehringfeld | ||
const QHash<QString, CuteEntityManager::Relation> Employee::getRelations() const {
|
|||
auto relations = Person::getRelations();
|
|||
return relations;
|
|||
}
|
|||
QString Employee::getDepartment() const {
|
|||
return department;
|
|||
}
|
|||
void Employee::setDepartment(const QString &value) {
|
|||
department = value;
|
|||
}
|
|||
bool Employee::isManager() const {
|
|||
return manager;
|
|||
}
|
|||
void Employee::setManager(bool value) {
|
|||
manager = value;
|
|||
}
|
|||
quint64 Employee::getPersNumber() const {
|
|||
return persNumber;
|
|||
}
|
|||
void Employee::setPersNumber(const quint64 &value) {
|
|||
persNumber = value;
|
|||
}
|
|||
const QHash<QString, CuteEntityManager::Relation> WorkerGroup::getRelations() const {
|
|||
auto hash = QHash<QString, CuteEntityManager::Relation>();
|
|||
hash.insert("workers", CuteEntityManager::Relation("workers",
|
|||
RelationType::MANY_TO_MANY));
|
|||
return hash;
|
|||
}
|
|||
QString WorkerGroup::getName() const {
|
|||
return name;
|
|||
}
|
|||
void WorkerGroup::setName(const QString &value) {
|
|||
name = value;
|
|||
}
|
|||
quint32 WorkerGroup::getEfficiency() const {
|
|||
return efficiency;
|
|||
}
|
|||
void WorkerGroup::setEfficiency(const quint32 &value) {
|
|||
efficiency = value;
|
|||
}
|
|||
bool WorkerGroup::isActive() const {
|
|||
return active;
|
|||
}
|
|||
void WorkerGroup::setActive(bool value) {
|
|||
active = value;
|
|||
}
|
|||
QList<QSharedPointer<Employee>> WorkerGroup::getWorkers() const {
|
|||
return workers;
|
|||
}
|
|||
void WorkerGroup::setWorkers(const QList<QSharedPointer<Employee>> &value) {
|
|||
workers = value;
|
|||
}
|
|||
20e1ffec | Christian Ehringfeld | ||
21826301 | Christian Ehringfeld | void WorkerGroup::addWorker(const QSharedPointer<Employee> &value) {
|
|
20e1ffec | Christian Ehringfeld | this->workers.append(value);
|
|
}
|