introduced field_attributes shortcuts and added method on_base() to all processor classes
This commit is contained in:
+6
-5
@@ -20,14 +20,15 @@ struct author {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "first_name", first_name, 63 );
|
||||
field::attribute( op, "last_name", last_name, 63 );
|
||||
field::attribute( op, "date_of_birth", date_of_birth, 31 );
|
||||
field::attribute( op, "first_name", first_name, VarChar63 );
|
||||
field::attribute( op, "last_name", last_name, VarChar63 );
|
||||
field::attribute( op, "date_of_birth", date_of_birth, VarChar63 );
|
||||
field::attribute( op, "year_of_birth", year_of_birth );
|
||||
field::attribute( op, "distinguished", distinguished );
|
||||
field::has_many( op, "books", books, "author_id", matador::utils::CascadeNoneFetchLazy );
|
||||
field::has_many( op, "books", books, "author_id", utils::CascadeNoneFetchLazy );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+4
-3
@@ -15,10 +15,11 @@ struct book {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "title", title, 511 );
|
||||
field::belongs_to( op, "author_id", book_author, matador::utils::CascadeNoneFetchLazy );
|
||||
field::attribute( op, "title", title, VarChar511 );
|
||||
field::belongs_to( op, "author_id", book_author, utils::CascadeNoneFetchLazy );
|
||||
field::attribute( op, "published_in", published_in );
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public:
|
||||
attribute() = default;
|
||||
attribute(std::string name,
|
||||
utils::basic_type type,
|
||||
const utils::field_attributes& opts = utils::NullAttributes,
|
||||
const utils::field_attributes& opts = matador::NullAttributes,
|
||||
null_option_type null_opt = null_option_type::NotNull)
|
||||
: name_(std::move(name)), type_(type), options_(opts), null_option_type_(null_opt) {}
|
||||
|
||||
|
||||
+10
-10
@@ -13,8 +13,7 @@
|
||||
namespace demo {
|
||||
|
||||
struct recipe;
|
||||
struct ingredient
|
||||
{
|
||||
struct ingredient {
|
||||
unsigned int id{};
|
||||
std::string name;
|
||||
matador::object::collection<matador::object::object_ptr<demo::recipe>> recipes{};
|
||||
@@ -25,15 +24,15 @@ struct ingredient
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", matador::utils::fetch_type::Eager);
|
||||
field::attribute(op, "name", name, VarChar255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", recipes, "ingredient_id", "recipe_id", utils::CascadeAllFetchEager);
|
||||
}
|
||||
};
|
||||
|
||||
struct recipe
|
||||
{
|
||||
struct recipe {
|
||||
unsigned int id{};
|
||||
std::string name;
|
||||
matador::object::collection<matador::object::object_ptr<demo::ingredient>> ingredients{};
|
||||
@@ -44,10 +43,11 @@ struct recipe
|
||||
|
||||
template<class Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key(op, "id", id);
|
||||
field::attribute(op, "name", name, 255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, matador::utils::fetch_type::Lazy);
|
||||
field::attribute(op, "name", name, VarChar255);
|
||||
field::has_many_to_many(op, "recipe_ingredients", ingredients, utils::CascadeAllFetchLazy);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+11
-8
@@ -81,11 +81,12 @@ struct profile {
|
||||
|
||||
template<typename Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "first_name", first_name, 255 );
|
||||
field::attribute( op, "last_name", last_name, 255 );
|
||||
field::belongs_to( op, "user_id", user, matador::utils::CascadeNoneFetchLazy );
|
||||
field::attribute( op, "first_name", first_name, VarChar255 );
|
||||
field::attribute( op, "last_name", last_name, VarChar255 );
|
||||
field::belongs_to( op, "user_id", user, utils::CascadeNoneFetchLazy );
|
||||
}
|
||||
};
|
||||
struct user {
|
||||
@@ -95,10 +96,11 @@ struct user {
|
||||
|
||||
template<typename Operator>
|
||||
void process(Operator &op) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "username", username, 255 );
|
||||
field::has_one(op, "profile_id", profile, matador::utils::CascadeNoneFetchLazy );
|
||||
field::attribute( op, "username", username, VarChar255 );
|
||||
field::has_one(op, "profile_id", profile, utils::CascadeNoneFetchLazy );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -108,9 +110,10 @@ struct person {
|
||||
|
||||
template<typename Operator>
|
||||
void process(Operator &op) {
|
||||
using namespace matador;
|
||||
namespace field = matador::access;
|
||||
field::primary_key( op, "id", id );
|
||||
field::attribute( op, "name", name, 255 );
|
||||
field::attribute( op, "name", name, VarChar255 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -36,12 +36,13 @@ struct CollectionCenter : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
using namespace matador;
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||
field::attribute( op, "symbol", symbol );
|
||||
field::attribute( op, "type", type );
|
||||
field::has_many( op, "collection_center_users", users, "users_id", matador::utils::fetch_type::Lazy );
|
||||
field::has_many( op, "collection_center_users", users, "users_id", utils::CascadeAllFetchLazy );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,4 +15,4 @@ struct InternalUserDirectory : UserDirectory {
|
||||
};
|
||||
}
|
||||
|
||||
#endif //INTERNALUSERDIRECTORY_HPP
|
||||
#endif //INTERNAL_USER_DIRECTORY_HPP
|
||||
|
||||
@@ -16,11 +16,12 @@ struct LdapGroupSchemaSettings : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
||||
field::attribute( op, "group_object_filter", group_object_filter, 511 );
|
||||
field::attribute( op, "user_member_attribute", user_member_attribute, 511 );
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||
field::attribute( op, "group_object_filter", group_object_filter, VarChar511 );
|
||||
field::attribute( op, "user_member_attribute", user_member_attribute, VarChar511 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17,10 +17,11 @@ struct LdapImportSettings : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
||||
field::attribute( op, "default_role", default_role, 511 );
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||
field::attribute( op, "default_role", default_role, VarChar511 );
|
||||
field::attribute( op, "sync_interval", sync_interval );
|
||||
field::attribute( op, "network_timeout", network_timeout );
|
||||
}
|
||||
|
||||
@@ -25,16 +25,17 @@ struct LdapUserDirectory : UserDirectory {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<UserDirectory>( this ) );
|
||||
field::attribute( op, "schema_base_dn", schema_base_dn, 511 );
|
||||
field::attribute( op, "additional_user_base_dn", additional_user_base_dn, 511 );
|
||||
field::attribute( op, "additional_group_base_dn", additional_group_base_dn, 511 );
|
||||
field::belongs_to( op, "user_schema_settings", user_schema_settings, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "group_schema_settings", group_schema_settings, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "import_settings", import_settings, matador::utils::CascadeAllFetchLazy );
|
||||
field::has_many( op, "ldap_users", users, "users_id", matador::utils::CascadeAllFetchEager );
|
||||
field::has_many( op, "ldap_groups", groups, "groups_id", matador::utils::CascadeAllFetchEager );
|
||||
field::attribute( op, "schema_base_dn", schema_base_dn, VarChar511 );
|
||||
field::attribute( op, "additional_user_base_dn", additional_user_base_dn, VarChar511 );
|
||||
field::attribute( op, "additional_group_base_dn", additional_group_base_dn, VarChar511 );
|
||||
field::belongs_to( op, "user_schema_settings", user_schema_settings, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "group_schema_settings", group_schema_settings, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "import_settings", import_settings, utils::CascadeAllFetchLazy );
|
||||
field::has_many( op, "ldap_users", users, "users_id", utils::CascadeAllFetchEager );
|
||||
field::has_many( op, "ldap_groups", groups, "groups_id", utils::CascadeAllFetchEager );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@ struct LdapUserSchemaSettings : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process(op, *matador::base_class<Model>( this ));
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, matador::utils::CascadeAllFetchLazy);
|
||||
field::attribute(op, "user_object_filter", user_object_filter, 511);
|
||||
field::attribute(op, "user_unique_id_attribute", user_unique_id_attribute, 511);
|
||||
field::attribute(op, "user_member_of_attribute", user_member_of_attribute, 511);
|
||||
field::attribute(op, "user_name_attribute", user_name_attribute, 511);
|
||||
field::has_one(op, "ldap_user_directory", ldap_user_directory, utils::CascadeAllFetchLazy);
|
||||
field::attribute(op, "user_object_filter", user_object_filter, VarChar511);
|
||||
field::attribute(op, "user_unique_id_attribute", user_unique_id_attribute, VarChar511);
|
||||
field::attribute(op, "user_member_of_attribute", user_member_of_attribute, VarChar511);
|
||||
field::attribute(op, "user_name_attribute", user_name_attribute, VarChar511);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -51,13 +51,14 @@ struct LoginHistory : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process_base<Model>( op, *this );
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::belongs_to( op, "client", client, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "scenario", scenario, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "collection_center", collection_center, matador::utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "login_name", login_name, 511 );
|
||||
field::belongs_to( op, "client", client, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "scenario", scenario, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "collection_center", collection_center, utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "login_name", login_name, VarChar511 );
|
||||
field::attribute( op, "fail_reason", fail_reason );
|
||||
field::attribute( op, "login_time", login_time );
|
||||
}
|
||||
|
||||
@@ -46,14 +46,15 @@ struct Scenario : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||
field::attribute( op, "mode", mode );
|
||||
field::attribute( op, "description", description, 511 );
|
||||
field::attribute( op, "description", description, VarChar511 );
|
||||
field::attribute( op, "symbol", symbol );
|
||||
field::attribute( op, "state", state );
|
||||
field::has_many( op, "collection_center", collection_center, "scenario_id", matador::utils::fetch_type::Lazy );
|
||||
field::has_many( op, "collection_center", collection_center, "scenario_id", utils::CascadeAllFetchLazy );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,17 +29,18 @@ struct User : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||
field::attribute( op, "symbol", symbol );
|
||||
field::attribute( op, "salt", salt, 511 );
|
||||
field::attribute( op, "password", password, 511 );
|
||||
field::attribute( op, "salt", salt, VarChar511 );
|
||||
field::attribute( op, "password", password, VarChar511 );
|
||||
field::attribute( op, "lock_type", lock_type );
|
||||
field::attribute( op, "locked_at", locked_at );
|
||||
field::attribute( op, "lock_reason", lock_reason, 511 );
|
||||
field::attribute( op, "role", role, 63 );
|
||||
field::belongs_to( op, "user_directory", user_directory, matador::utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "lock_reason", lock_reason, VarChar511 );
|
||||
field::attribute( op, "role", role, VarChar63 );
|
||||
field::belongs_to( op, "user_directory", user_directory, utils::CascadeAllFetchLazy );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ struct UserDirectory : core::Model {
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "name", name, matador::VarChar511 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,11 +21,12 @@ struct UserSession : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
namespace field = access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::belongs_to( op, "client", client, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "scenario", scenario, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "collection_center", collection_center, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "client", client, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "scenario", scenario, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "collection_center", collection_center, utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "offline_since", offline_since );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define USERINFO_HPP
|
||||
|
||||
#include "matador/utils/access.hpp"
|
||||
#include "matador/utils/field_attributes.hpp"
|
||||
|
||||
namespace work::core {
|
||||
struct UserInfo {
|
||||
@@ -12,9 +13,10 @@ struct UserInfo {
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
namespace field = matador::access;
|
||||
using namespace matador;
|
||||
field::attribute( op, "user_session_id", user_session_id );
|
||||
field::attribute( op, "user_role", user_role, 255 );
|
||||
field::attribute( op, "database_name", database_name, 255 );
|
||||
field::attribute( op, "user_role", user_role, VarChar255 );
|
||||
field::attribute( op, "database_name", database_name, VarChar255 );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -30,15 +30,16 @@ struct Job : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
using namespace matador;
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "description", description, 511 );
|
||||
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||
field::attribute( op, "description", description, VarChar1023 );
|
||||
field::attribute( op, "state", state );
|
||||
field::attribute( op, "mode", mode );
|
||||
field::attribute( op, "created_at", created_at );
|
||||
field::has_one(op, "payload", payload, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "task", task, matador::utils::CascadeAllFetchLazy );
|
||||
field::has_one(op, "payload", payload, utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "task", task, utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "user_info", user_info );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,10 +16,11 @@ struct Payload : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
using namespace matador;
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "type", type, 255 );
|
||||
field::belongs_to( op, "job", job, matador::utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "type", type, VarChar255 );
|
||||
field::belongs_to( op, "job", job, utils::CascadeAllFetchLazy );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,13 +26,14 @@ struct Task : core::Model {
|
||||
|
||||
template<typename Operator>
|
||||
void process( Operator& op ) {
|
||||
using namespace matador;
|
||||
namespace field = matador::access;
|
||||
field::process( op, *matador::base_class<Model>( this ) );
|
||||
field::attribute( op, "name", name, 511 );
|
||||
field::attribute( op, "description", description, 511 );
|
||||
field::attribute( op, "job_name", job_name, 511 );
|
||||
field::attribute( op, "name", name, UniqueVarChar511 );
|
||||
field::attribute( op, "description", description, VarChar1023 );
|
||||
field::attribute( op, "job_name", job_name, VarChar511 );
|
||||
field::attribute( op, "state", state );
|
||||
field::belongs_to( op, "payload", payload, matador::utils::CascadeAllFetchLazy );
|
||||
field::belongs_to( op, "payload", payload, utils::CascadeAllFetchLazy );
|
||||
field::attribute( op, "job_mode", job_mode );
|
||||
field::attribute( op, "start_delay", start_delay );
|
||||
field::attribute( op, "interval", interval );
|
||||
|
||||
Reference in New Issue
Block a user