*/
class UsersController extends AppController
{
-
+
/**
* Index method
*
public function view($id = null)
{
$user = $this->Users->get($id, [
- 'contain' => ['UserTypes','RelationshipsSoftwares', 'Relationships', 'Reviews']
- // 'contain'=>['UserTypes','Reviews']
- ]);
-
-
-
- $creatorOfSoftwares = $this->getRelationsByUserId($id, 'CreatorOf');
- $userSoftwares = $this->getRelationsByUserId($id, 'UserOf');
- $backerSoftwares = $this->getRelationsByUserId($id, 'BackerOf');
- $contributorSoftwares = $this->getRelationsByUserId($id, 'ContributorOf');
- $providerForSoftwares = $this->getRelationsByUserId($id, 'ServicesProvider');
-
- $this->set(compact('user','creatorOfSoftwares','userSoftwares','backerSoftwares','contributorSoftwares','providerForSoftwares'));
-
- $this->set('_serialize', ['user','creatorOfSoftwares','userSoftwares','backerSoftwares','contributorSoftwares','providerForSoftwares','users']);
+ 'contain' => [
+ 'UserTypes',
+ 'Reviews',
+ 'Usedsoftwares' => [
+ 'Softwares' => [
+ 'fields' => [
+ 'id',
+ 'softwarename',
+ 'logo_directory',
+ 'photo',
+ 'description'
+ ]
+ ]
+ ],
+ "Backedsoftwares" =>[
+ 'Softwares' => [
+ 'fields' => [
+ 'id',
+ 'softwarename',
+ 'logo_directory',
+ 'photo',
+ 'description'
+ ]
+ ]
+ ],
+ "Createdsoftwares" =>[
+ 'Softwares' => [
+ 'fields' => [
+ 'id',
+ 'softwarename',
+ 'logo_directory',
+ 'photo',
+ 'description'
+ ]
+ ]
+ ],
+ "Contributionssoftwares" =>[
+ 'Softwares' => [
+ 'fields' => [
+ 'id',
+ 'softwarename',
+ 'logo_directory',
+ 'photo',
+ 'description'
+ ]
+ ]
+ ],
+ "Providerforsoftwares" =>[
+ 'Softwares' => [
+ 'fields' => [
+ 'id',
+ 'softwarename',
+ 'logo_directory',
+ 'photo',
+ 'description'
+ ]
+ ]
+ ],
+ ]
+ ]);
+ $this->set(compact('user'));
+ $this->set('_serialize', 'user');
}
- /**
- *
- * @param Integer $id reprensent the user id
- * @param String $typeOfRelation represent the name of the relation (filed => 'cd')
- * @return type
- */
- private function getRelationsByUserId($id,$typeOfRelation){
-
- $RelationshipsSoftwaresUsersTable = TableRegistry::get('relationships_softwares_users');
-
- if (!empty($this->Users->Relationships->find('all')
- ->select('id')
- ->where(['relationships.cd = ' => $typeOfRelation])
- ->toArray()) ){
- $relationId = $this->Users->Relationships->find('all')
- ->select('id')
- ->where(['relationships.cd = ' => $typeOfRelation])
- ->toArray()[0]->id;
-
- // Get the all relationships between an user and softwares
- $relations = $RelationshipsSoftwaresUsersTable->find('all')
- ->contain(['Relationships'])->where(["relationships_softwares_users.user_id = " =>$id])
- ->where(['relationships_softwares_users.relationship_id = '=> $relationId]);
- }
- return $relations ;
+ public function FindByType (){
+
+ $UserType = $this->request->params['pass'];
+
+ $this->paginate = [
+ 'finder' => [
+ 'ByType' => $UserType
+ ]
+ ];
+
+ $users = $this->paginate($this->Users);
+
+ $this->$this->set(compact('users'));
+ $this->set('_serialize', 'users');
}
-
public function getUsersByType(){
try {
$users = $this->Users->find("all")->contain(["UserTypes"])
'message' => "Success",
'users' => $this->paginate($users),
'_serialize' => ['message', 'users']
- ]);
+ ]);
}catch(Exception $e){
-
+
}
-
+
}
/**
// if is a json
if ($this->request->is('post') && $this->request->is('json')) {
$user = $this->Users->patchEntity($user, $this->request->data);
- if ($this->Users->save($user) ) {
+ if ($this->Users->save($user) ) {
$message = "success";
} else {
$message = "Error";
'message' => $message,
'user' => $user,
'_serialize' => ['message', 'user']
- ]);
+ ]);
// if is not a json
}else if ($this->request->is('post') && !$this->request->is('json')){
$user = $this->Users->patchEntity($user, $this->request->data);
$userTypes = $this->Users->UserTypes->find('list', ['limit' => 200]);
$this->set(compact('user', 'userTypes'/*, 'relationshipsSoftwares', 'relationships'*/));
$this->set('_serialize', ['user']);
- }
+ }
}
/**
if ($this->request->is(['patch', 'post', 'put']) && $this->request->is('json')) {
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
- $message = "success";
+ $message = "success";
} else {
$message = "Error";
}
'message' => $message,
'user' => $user,
'_serialize' => ['message', 'user']
- ]);
+ ]);
}
else if ($this->request->is(['patch', 'post', 'put']) && !$this->request->is('json')){
$user = $this->Users->patchEntity($user, $this->request->data);
if ($this->Users->save($user)) {
- $this->Flash->success(__('The user has been saved.'));
+ $this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The user could not be saved. Please, try again.'));
- }
+ }
$userTypes = $this->Users->UserTypes->find('list', ['limit' => 200]);
$this->set(compact('user', 'userTypes'/*, 'relationshipsSoftwares', 'relationships'*/));
}else {// Pour le template avant le poste des données.
$userTypes = $this->Users->UserTypes->find('list', ['limit' => 200]);
$this->set(compact('user', 'userTypes'/*, 'relationshipsSoftwares', 'relationships'*/));
- $this->set('_serialize', ['user']);
- }
+ $this->set('_serialize', ['user']);
+ }
}
-
- /**
- *
+
+ /**
+ *
*/
public function isAdministration (){
try {
$user = $this->Users->get($this->request->query["id"], [
'contain' => ['UserTypes',]
]);
-
+
$this->set([
'message' => "Success",
'user' => $user,
'_serialize' => ['message', 'user']
- ]);
+ ]);
}catch(Exception $e){
-
+
}
}
return $this->redirect(['action' => 'index']);
}
-
-
+
+
public function login()
- {
+ {
$message = "test";
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
$message ="Success";
-
+
}else {
$message = __("Bad Username or bad password");
}
'message' => $message,
'user' => $user,
'_serialize' => ['message', 'user']
- ]);
+ ]);
}else{
$this->set([
'message' => $message,
'_serialize' => ['message']
- ]);
+ ]);
}
-
+
}
public function logout()
{
return $this->redirect($this->Auth->logout());
}
-
+
/**
- * Manage all rights for the controllers' actions.
+ * Manage all rights for the controllers' actions.
* Returns true if the user can use the currrent action, FALSE otherwise.
* Returns true for add a project if the user is connected
- * Returns true for edit and delete action if the user is owner.
+ * Returns true for edit and delete action if the user is owner.
* @param Array $user
* @return boolean
*/
$this->Auth->allow();
return parent::isAuthorized($user);
}
-
-
+
+
public function initialize(){
-
-
+
+
parent::initialize();
-
+
$this->paginate = [
'limit' => Configure::read('LIMIT'),
'order' => [
+++ /dev/null
-<?php
-namespace App\Model\Entity;
-
-use Cake\ORM\Entity;
-
-/**
- * Entity Entity.
- *
- * @property int $ENTITY_id
- * @property \App\Model\Entity\ENTITy $e_n_t_i_ty
- * @property string $ENTITY_name
- * @property \Cake\I18n\Time $ENTITY_registration_date
- * @property string $ENTITY_logo_url
- * @property string $ENTITY_url
- * @property int $ENTITY_type
- * @property string $ENTITY_description
- */
-class Entity extends Entity
-{
-
- /**
- * Fields that can be mass assigned using newEntity() or patchEntity().
- *
- * Note that when '*' is set to true, this allows all unspecified fields to
- * be mass assigned. For security purposes, it is advised to set '*' to false
- * (or remove it), and explicitly make individual fields accessible as needed.
- *
- * @var array
- */
- protected $_accessible = [
- '*' => true,
- 'ENTITY_id' => false,
- 'ENTITY_type' => false,
- ];
-}
+++ /dev/null
-<?php
-namespace App\Model\Entity;
-
-use Cake\ORM\Entity;
-
-/**
- * EntitySoftwareRelationship Entity.
- *
- * @property int $ENTITY_SOFTWARE_RELATIONSHIP_software_id
- * @property \App\Model\Entity\ENTITYSOFTWARERELATIONSHIPSoftware $e_n_t_i_t_y_s_o_f_t_w_a_r_e_r_e_l_a_t_i_o_n_s_h_i_p_software
- * @property int $ENTITY_SOFTWARE_RELATIONSHIP_entity_id
- * @property \App\Model\Entity\ENTITYSOFTWARERELATIONSHIPEntity $e_n_t_i_t_y_s_o_f_t_w_a_r_e_r_e_l_a_t_i_o_n_s_h_i_p_entity
- * @property int $ENTITY_SOFTWARE_RELATIONSHIP_relationship_type_id
- * @property \App\Model\Entity\RelationshipType $relationship_type
- */
-class EntitySoftwareRelationship extends Entity
-{
-
- /**
- * Fields that can be mass assigned using newEntity() or patchEntity().
- *
- * Note that when '*' is set to true, this allows all unspecified fields to
- * be mass assigned. For security purposes, it is advised to set '*' to false
- * (or remove it), and explicitly make individual fields accessible as needed.
- *
- * @var array
- */
- protected $_accessible = [
- '*' => true,
- 'ENTITY_SOFTWARE_RELATIONSHIP_software_id' => false,
- 'ENTITY_SOFTWARE_RELATIONSHIP_entity_id' => false,
- ];
-}
use Cake\ORM\Entity;
/**
- * LicenceType Entity.
+ * LicnseType Entity.
*
- * @property int $id
- * @property string $name
- * @property \Cake\I18n\Time $created
- * @property \Cake\I18n\Time $modified
- * @property string $cd
+ * @property int $LICENSE_TYPE_id
+ * @property \App\Model\Entity\LICENSETYPE $l_i_c_e_n_s_e_t_y_p_e
+ * @property string $LICENSE_TYPE_value
*/
class LicenceType extends Entity
{
*/
protected $_accessible = [
'*' => true,
- 'id' => false,
+ 'LICENSE_TYPE_id' => false,
];
}
use Cake\ORM\Entity;
/**
- * LicnseType Entity.
+ * Panel Entity.
*
- * @property int $LICENSE_TYPE_id
- * @property \App\Model\Entity\LICENSETYPE $l_i_c_e_n_s_e_t_y_p_e
- * @property string $LICENSE_TYPE_value
+ * @property string $id
+ * @property string $request_id
+ * @property \App\Model\Entity\Request $request
+ * @property string $panel
+ * @property string $title
+ * @property string $element
+ * @property string $summary
+ * @property string|resource $content
*/
-class LicnseType extends Entity
+class Panel extends Entity
{
/**
*/
protected $_accessible = [
'*' => true,
- 'LICENSE_TYPE_id' => false,
+ 'id' => false,
];
}
use Cake\ORM\Entity;
/**
- * EntityType Entity.
+ * Request Entity.
*
- * @property int $ENTITY_TYPE_id
- * @property \App\Model\Entity\ENTITYTYPE $e_n_t_i_t_y_t_y_p_e
- * @property string $ENTITY_TYPE_value
+ * @property string $id
+ * @property string $url
+ * @property string $content_type
+ * @property int $status_code
+ * @property string $method
+ * @property \Cake\I18n\Time $requested_at
+ * @property \App\Model\Entity\Panel[] $panels
*/
-class EntityType extends Entity
+class Request extends Entity
{
/**
*/
protected $_accessible = [
'*' => true,
- 'ENTITY_TYPE_id' => false,
+ 'id' => false,
];
}
$this->primaryKey('id');
$this->addBehavior('Timestamp');
-
}
/**
->allowEmpty('id', 'create');
$validator
- ->requirePresence('name', 'create')
- ->notEmpty('name');
+ ->allowEmpty('name');
$validator
->allowEmpty('cd');
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Panel;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Panels Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Requests
+ */
+class PanelsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('panels');
+ $this->displayField('title');
+ $this->primaryKey('id');
+
+ $this->belongsTo('Requests', [
+ 'foreignKey' => 'request_id',
+ 'joinType' => 'INNER'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->uuid('id')
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('panel');
+
+ $validator
+ ->allowEmpty('title');
+
+ $validator
+ ->allowEmpty('element');
+
+ $validator
+ ->allowEmpty('summary');
+
+ $validator
+ ->allowEmpty('content');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['request_id'], 'Requests'));
+ return $rules;
+ }
+}
->integer('code_gouv_label')
->allowEmpty('code_gouv_label');
+ $validator
+ ->dateTime('metrics_date')
+ ->allowEmpty('metrics_date');
+
+ $validator
+ ->integer('project_age')
+ ->allowEmpty('project_age');
+
+ $validator
+ ->integer('delta_commit_one_month')
+ ->allowEmpty('delta_commit_one_month');
+
+ $validator
+ ->integer('delta_commit_twelve_month')
+ ->allowEmpty('delta_commit_twelve_month');
+
return $validator;
}
return $validator;
}
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->isUnique(['name']));
+ $rules->add($rules->isUnique(['cd']));
+ return $rules;
+ }
}
'joinType' => 'INNER'
]);
$this->belongsToMany('Users', [
- 'foreignKey' => 'software_id',
+ 'foreignKey' => 'relationships_software_id',
'targetForeignKey' => 'user_id',
'joinTable' => 'relationships_softwares_users'
]);
{
$validator
->allowEmpty('id', 'create');
+
return $validator;
}
* Relationships Model
*
* @property \Cake\ORM\Association\BelongsTo $RelationshipTypes
+ * @property \Cake\ORM\Association\HasMany $RelationshipsSoftwaresUsers
* @property \Cake\ORM\Association\BelongsToMany $Softwares
* @property \Cake\ORM\Association\BelongsToMany $Users
*/
$this->addBehavior('Timestamp');
-
- $this->addBehavior('Translate', ['fields' => ['title', 'body']]);
-
$this->belongsTo('RelationshipTypes', [
'foreignKey' => 'relationship_type_id'
]);
+ $this->hasMany('RelationshipsSoftwaresUsers', [
+ 'foreignKey' => 'relationship_id'
+ ]);
$this->belongsToMany('Softwares', [
'foreignKey' => 'relationship_id',
'targetForeignKey' => 'software_id',
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Request;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Requests Model
+ *
+ * @property \Cake\ORM\Association\HasMany $Panels
+ */
+class RequestsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('requests');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->hasMany('Panels', [
+ 'foreignKey' => 'request_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->uuid('id')
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->requirePresence('url', 'create')
+ ->notEmpty('url');
+
+ $validator
+ ->allowEmpty('content_type');
+
+ $validator
+ ->integer('status_code')
+ ->allowEmpty('status_code');
+
+ $validator
+ ->allowEmpty('method');
+
+ $validator
+ ->dateTime('requested_at')
+ ->requirePresence('requested_at', 'create')
+ ->notEmpty('requested_at');
+
+ return $validator;
+ }
+}
$this->addBehavior('Timestamp');
- //For upload file -> avatar
- $this->addBehavior('Josegonzalez/Upload.Upload', [
- 'photo' => [
- 'fields' => [
- 'dir' => 'url_directory',
- ],
- 'path' => 'files{DS}{model}',
- ],
- ]);
-
-
-
$this->belongsTo('Softwares', [
'foreignKey' => 'software_id'
]);
->allowEmpty('id', 'create');
$validator
- ->allowEmpty('name');
-
-// $validator
-// ->requirePresence('photo', 'create')
-// ->notEmpty('photo');
+ ->allowEmpty('url_directory');
$validator
- ->allowEmpty('url_directory');
+ ->allowEmpty('name');
+
$validator
->allowEmpty('photo');
-
- $validator->provider('upload',new \Josegonzalez\Upload\Validation\DefaultValidation());
-
- $validator->add('photo', 'fileBelowMaxSize', [
- 'rule' => ['isBelowMaxSize', 1000000],
- 'message' => 'This file is too large',
- 'provider' => 'upload'
- ]);
-
-
- //Check that the file is below the maximum height requirement (checked in pixels)
- $validator->add('photo', 'fileBelowMaxHeight', [
- 'rule' => ['isBelowMaxHeight', 1080],
- 'message' => 'This image should not be higher than 500px',
- 'provider' => 'upload'
- ]);
-
- $validator->add('photo','file',[
- 'rule' => ['mimeType', ['image/jpeg', 'image/png','image/gif','image/svg+xml']],
- 'message' => "This format is not allowed"
- ]);
-
-
- // Check that the file is below the maximum height requirement (checked in pixels)
- $validator->add('photo', 'fileAboveMinHeight', [
- 'rule' => ['isAboveMinHeight', 100],
- 'message' => 'This image should at least be 150px high',
- 'provider' => 'upload'
- ]);
-
return $validator;
}
use Cake\ORM\RulesChecker;
use Cake\ORM\Table;
use Cake\Validation\Validator;
-use Search\Manager;
+
/**
* Softwares Model
*
* @property \Cake\ORM\Association\BelongsTo $Licenses
+ * @property \Cake\ORM\Association\HasMany $RawMetricsSoftwares
* @property \Cake\ORM\Association\HasMany $RelationshipsSoftwaresUsers
* @property \Cake\ORM\Association\HasMany $Reviews
* @property \Cake\ORM\Association\HasMany $Screenshots
parent::initialize($config);
$this->table('softwares');
- $this->displayField('softwarename');
+ $this->displayField('id');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
- //For upload file -> avatar
- $this->addBehavior('Josegonzalez/Upload.Upload', [
- 'photo' => [
- 'fields' => [
- 'dir' => 'logo_directory',
- ],
- 'path' => 'files{DS}{model}{DS}{primaryKey}{DS}{field}{DS}avatar',
- ],
- ]);
$this->belongsTo('Licenses', [
'foreignKey' => 'licence_id'
]);
- $this->hasOne('RawMetricsSoftwares', [
+ $this->hasMany('RawMetricsSoftwares', [
'foreignKey' => 'software_id'
]);
$this->hasMany('RelationshipsSoftwaresUsers', [
$this->hasMany('Screenshots', [
'foreignKey' => 'software_id'
]);
- $this->hasMany('SoftwaresStatistics', [
+ $this->hasOne('SoftwaresStatistics', [
'foreignKey' => 'software_id'
]);
$this->belongsToMany('Relationships', [
'targetForeignKey' => 'relationship_id',
'joinTable' => 'relationships_softwares'
]);
-
-
-
- // #######################
- // ##### For search ######
- // #######################
-
- // Add the behaviour to your table
- $this->addBehavior('Search.Search');
-
- // Setup search filter using search manager
- $this->searchManager()
- ->value('id')
- // Here we will alias the 'q' query param to search the `Articles.title`
- // field and the `Articles.content` field, using a LIKE match, with `%`
- // both before and after.
- ->add('q', 'Search.Like', [
- 'before' => true,
- 'after' => true,
- 'mode' => 'or',
- 'comparison' => 'ILIKE',
- 'wildcardAny' => '*',
- 'wildcardOne' => '?',
- 'field' => [$this->aliasField('softwarename'), $this->aliasField('description')]
- ]);
-// ->add('foo', 'Search.Callback', [
-// 'callback' => function ($query, $args, $filter) {
-// // Modify $query as required
-// }
-// ]);
}
-
+
/**
* Default validation rules.
*
$validator
->allowEmpty('photo');
-
-
- $validator->add('photo','file',[
- 'rule' => ['mimeType', ['image/jpeg', 'image/png','image/gif','image/svg+xml']],
- 'message' => "This format is not allowed"
- ]);
-
-
- $validator->provider('uploadImage',new \Josegonzalez\Upload\Validation\ImageValidation());
-
- //Check that the file is below the maximum height requirement (checked in pixels)
- $validator->add('photo', 'fileBelowMaxHeight', [
- 'rule' => ['isBelowMaxHeight', 250],
- 'message' => 'This image should not be higher than 500px',
- 'provider' => 'uploadImage'
- ]);
-
-
- // Check that the file is Above the minimum height requirement (checked in pixels)
- $validator->add('photo', 'fileAboveMinHeight', [
- 'rule' => ['isAboveMinHeight', 100],
- 'message' => 'This image should at least be 150px high',
- 'provider' => 'uploadImage'
- ]);
-
-
-
- $validator->provider('upload',new \Josegonzalez\Upload\Validation\UploadValidation());
-
- $validator->add('photo', 'fileBelowMaxSize', [
- 'rule' => ['isBelowMaxSize', 1000000],
- 'message' => 'This file is too large',
- 'provider' => 'upload'
- ]);
-
-
-
-
return $validator;
}
use Cake\ORM\Table;
use Cake\Validation\Validator;
-/**
- * For authentification
- */
-use Cake\Auth\DefaultPasswordHasher;
-use Cake\Utility\Text;
-use Cake\Event\Event;
-
/**
* Users Model
*
parent::initialize($config);
$this->table('users');
- $this->displayField('username');
+ $this->displayField('id');
$this->primaryKey('id');
$this->addBehavior('Timestamp');
-
- //For upload file -> avatar
- $this->addBehavior('Josegonzalez/Upload.Upload', [
- 'photo' => [
- 'fields' => [
- 'dir' => 'logo_directory',
- ],
- 'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}{primaryKey}{DS}avatar',
- ],
- ]);
+ //----------------------------------------------------------------------
+ //-------------------------Logique BDD----------------------------------
+ //----------------------------------------------------------------------
$this->belongsTo('UserTypes', [
'foreignKey' => 'user_type_id',
'joinType' => 'INNER'
$this->hasMany('Reviews', [
'foreignKey' => 'user_id'
]);
- $this->belongsToMany('RelationshipsSoftwares', [
+ $this->hasMany('RelationshipsSoftwaresUsers', [
'foreignKey' => 'user_id',
- 'targetForeignKey' => 'relationship_id',
+ 'targetForeignKey' => 'software_id',
'joinTable' => 'relationships_softwares_users'
]);
$this->belongsToMany('Relationships', [
'foreignKey' => 'user_id',
- 'targetForeignKey' => 'recipient_id',
+ 'targetForeignKey' => 'relationship_id',
'joinTable' => 'relationships_users'
]);
+
+ //----------------------------------------------------------------------
+ //-------------------------Logique applicative--------------------------
+ //----------------------------------------------------------------------
+
+ /**
+ * Used softwares
+ */
+ $this->hasMany(
+ 'Usedsoftwares',
+ [
+ 'className' => 'RelationshipsSoftwaresUsers',
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares_users',
+ 'conditions' => [
+ 'relationship_id' => 7
+ ]
+ ]
+ );
+
+ /**
+ * Backed softwares
+ */
+ $this->hasMany(
+ 'Backedsoftwares',
+ [
+ 'className' => 'RelationshipsSoftwaresUsers',
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares_users',
+ 'conditions' => [
+ 'relationship_id' => 8
+ ]
+ ]
+ );
+ $this->hasMany(
+ 'Createdsoftwares',
+ [
+ 'className' => 'RelationshipsSoftwaresUsers',
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares_users',
+ 'conditions' => [
+ 'relationship_id' => 3
+ ]
+ ]
+ );
+ /**
+ * Contributior to
+ */
+ $this->hasMany(
+ 'Contributionssoftwares',
+ [
+ 'className' => 'RelationshipsSoftwaresUsers',
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares_users',
+ 'conditions' => [
+ 'relationship_id' => 3
+ ]
+ ]
+ );
+ /**
+ * Provider For
+ */
+ $this->hasMany(
+ 'Providerforsoftwares',
+ [
+ 'className' => 'RelationshipsSoftwaresUsers',
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares_users',
+ 'conditions' => [
+ 'relationship_id' => 3
+ ]
+ ]
+ );
+
+ }
+
+ public function findByType(Query $query, array $options)
+ {
+ $query->where([
+ "UserTypes.cd" => "Administration"
+ ]);
+ return $query;
}
/**
->notEmpty('password');
$validator
- ->add('email', 'valid', ['rule' => 'email'])
+ ->email('email')
->allowEmpty('email');
$validator
$rules->add($rules->existsIn(['user_type_id'], 'UserTypes'));
return $rules;
}
-
-
- /**
- * Before save an user
- * @param \App\Controller\Api\V1\Event $event
- * @return boolean
- */
- public function beforeSave(Event $event)
- {
- $entity = $event->data['entity'];
-
- if ($entity->isNew()) {
- $hasher = new DefaultPasswordHasher();
-
- // Generate an API 'token'
- $entity->api_key_plain = sha1(Text::uuid());
-
- // Bcrypt the token so BasicAuthenticate can check
- // it during login.
- $entity->api_key = $hasher->hash($entity->api_key_plain);
- }
- return true;
- }
}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\LicenceType;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * LicenceTypes Model
+ *
+ */
+class LicenceTypesTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('licence_types');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->requirePresence('name', 'create')
+ ->notEmpty('name');
+
+ $validator
+ ->allowEmpty('cd');
+
+ return $validator;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\License;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Licenses Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $LicenceTypes
+ */
+class LicensesTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('licenses');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('LicenceTypes', [
+ 'foreignKey' => 'license_type_id',
+ 'joinType' => 'INNER'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->requirePresence('name', 'create')
+ ->notEmpty('name');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['license_type_id'], 'LicenceTypes'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\RawMetricsSoftware;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * RawMetricsSoftwares Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ */
+class RawMetricsSoftwaresTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('raw_metrics_softwares');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->integer('id')
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('name');
+
+ $validator
+ ->integer('last_commit_age')
+ ->requirePresence('last_commit_age', 'create')
+ ->notEmpty('last_commit_age');
+
+ $validator
+ ->numeric('high_committer_percent')
+ ->requirePresence('high_committer_percent', 'create')
+ ->notEmpty('high_committer_percent');
+
+ $validator
+ ->integer('number_of_contributors')
+ ->requirePresence('number_of_contributors', 'create')
+ ->notEmpty('number_of_contributors');
+
+ $validator
+ ->integer('declared_users')
+ ->allowEmpty('declared_users');
+
+ $validator
+ ->decimal('average_review_score')
+ ->allowEmpty('average_review_score');
+
+ $validator
+ ->integer('screenshots')
+ ->allowEmpty('screenshots');
+
+ $validator
+ ->integer('code_gouv_label')
+ ->allowEmpty('code_gouv_label');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\RelationshipType;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * RelationshipTypes Model
+ *
+ * @property \Cake\ORM\Association\HasMany $Relationships
+ */
+class RelationshipTypesTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('relationship_types');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->hasMany('Relationships', [
+ 'foreignKey' => 'relationship_type_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('name')
+ ->add('name', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
+
+ $validator
+ ->allowEmpty('cd')
+ ->add('cd', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
+
+ return $validator;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\RelationshipsSoftware;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * RelationshipsSoftwares Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ * @property \Cake\ORM\Association\BelongsTo $Relationships
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ * @property \Cake\ORM\Association\BelongsToMany $Users
+ */
+class RelationshipsSoftwaresTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('relationships_softwares');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Relationships', [
+ 'foreignKey' => 'relationship_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'recipient_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsToMany('Users', [
+ 'foreignKey' => 'software_id',
+ 'targetForeignKey' => 'user_id',
+ 'joinTable' => 'relationships_softwares_users'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ $rules->add($rules->existsIn(['relationship_id'], 'Relationships'));
+ $rules->add($rules->existsIn(['recipient_id'], 'Softwares'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\RelationshipsSoftwaresUser;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * RelationshipsSoftwaresUsers Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ * @property \Cake\ORM\Association\BelongsTo $Users
+ * @property \Cake\ORM\Association\BelongsTo $Relationships
+ */
+class RelationshipsSoftwaresUsersTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('relationships_softwares_users');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Users', [
+ 'foreignKey' => 'user_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Relationships', [
+ 'foreignKey' => 'relationship_id',
+ 'joinType' => 'INNER'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ $rules->add($rules->existsIn(['user_id'], 'Users'));
+ $rules->add($rules->existsIn(['relationship_id'], 'Relationships'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Relationship;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Relationships Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $RelationshipTypes
+ * @property \Cake\ORM\Association\BelongsToMany $Softwares
+ * @property \Cake\ORM\Association\BelongsToMany $Users
+ */
+class RelationshipsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('relationships');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+
+ $this->addBehavior('Translate', ['fields' => ['title', 'body']]);
+
+ $this->belongsTo('RelationshipTypes', [
+ 'foreignKey' => 'relationship_type_id'
+ ]);
+
+ $this->belongsToMany('Softwares', [
+ 'foreignKey' => 'relationship_id',
+ 'targetForeignKey' => 'software_id',
+ 'joinTable' => 'relationships_softwares'
+ ]);
+ $this->belongsToMany('Users', [
+ 'foreignKey' => 'relationship_id',
+ 'targetForeignKey' => 'user_id',
+ 'joinTable' => 'relationships_users'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->requirePresence('name', 'create')
+ ->notEmpty('name');
+
+ $validator
+ ->allowEmpty('cd');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['relationship_type_id'], 'RelationshipTypes'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\RelationshipsUser;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * RelationshipsUsers Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Users
+ * @property \Cake\ORM\Association\BelongsTo $Users
+ * @property \Cake\ORM\Association\BelongsTo $Relationships
+ */
+class RelationshipsUsersTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('relationships_users');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('Users', [
+ 'foreignKey' => 'user_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Users', [
+ 'foreignKey' => 'recipient_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->belongsTo('Relationships', [
+ 'foreignKey' => 'relationship_id',
+ 'joinType' => 'INNER'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['user_id'], 'Users'));
+ $rules->add($rules->existsIn(['recipient_id'], 'Users'));
+ $rules->add($rules->existsIn(['relationship_id'], 'Relationships'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Review;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Reviews Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Users
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ */
+class ReviewsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('reviews');
+ $this->displayField('title');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->belongsTo('Users', [
+ 'foreignKey' => 'user_id'
+ ]);
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->requirePresence('comment', 'create')
+ ->notEmpty('comment');
+
+ $validator
+ ->requirePresence('title', 'create')
+ ->notEmpty('title');
+
+ $validator
+ ->allowEmpty('evaluation');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['user_id'], 'Users'));
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Screenshot;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * Screenshots Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ */
+class ScreenshotsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('screenshots');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ //For upload file -> avatar
+ $this->addBehavior('Josegonzalez/Upload.Upload', [
+ 'photo' => [
+ 'fields' => [
+ 'dir' => 'url_directory',
+ ],
+ 'path' => 'files{DS}{model}',
+ ],
+ ]);
+
+
+
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('name');
+
+// $validator
+// ->requirePresence('photo', 'create')
+// ->notEmpty('photo');
+
+ $validator
+ ->allowEmpty('url_directory');
+ $validator
+ ->allowEmpty('photo');
+
+ $validator->provider('upload',new \Josegonzalez\Upload\Validation\DefaultValidation());
+
+
+ $validator->add('photo', 'fileBelowMaxSize', [
+ 'rule' => ['isBelowMaxSize', 1000000],
+ 'message' => 'This file is too large',
+ 'provider' => 'upload'
+ ]);
+
+
+ //Check that the file is below the maximum height requirement (checked in pixels)
+ $validator->add('photo', 'fileBelowMaxHeight', [
+ 'rule' => ['isBelowMaxHeight', 1080],
+ 'message' => 'This image should not be higher than 500px',
+ 'provider' => 'upload'
+ ]);
+
+ $validator->add('photo','file',[
+ 'rule' => ['mimeType', ['image/jpeg', 'image/png','image/gif','image/svg+xml']],
+ 'message' => "This format is not allowed"
+ ]);
+
+
+ // Check that the file is below the maximum height requirement (checked in pixels)
+ $validator->add('photo', 'fileAboveMinHeight', [
+ 'rule' => ['isAboveMinHeight', 100],
+ 'message' => 'This image should at least be 150px high',
+ 'provider' => 'upload'
+ ]);
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\SoftwaresStatistic;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * SoftwaresStatistics Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Softwares
+ */
+class SoftwaresStatisticsTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('softwares_statistics');
+ $this->displayField('id');
+ $this->primaryKey('id');
+
+ $this->belongsTo('Softwares', [
+ 'foreignKey' => 'software_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->integer('id')
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->integer('last_commit_age')
+ ->allowEmpty('last_commit_age');
+
+ $validator
+ ->integer('project_age')
+ ->allowEmpty('project_age');
+
+ $validator
+ ->integer('delta_commit_one_month')
+ ->allowEmpty('delta_commit_one_month');
+
+ $validator
+ ->integer('delta_commit_one_year')
+ ->allowEmpty('delta_commit_one_year');
+
+ $validator
+ ->integer('nb_contributors')
+ ->allowEmpty('nb_contributors');
+
+ $validator
+ ->decimal('contributors_code_percent')
+ ->allowEmpty('contributors_code_percent');
+
+ $validator
+ ->integer('declared_users')
+ ->allowEmpty('declared_users');
+
+ $validator
+ ->decimal('average_review_score')
+ ->allowEmpty('average_review_score');
+
+ $validator
+ ->integer('screenshots')
+ ->allowEmpty('screenshots');
+
+ $validator
+ ->integer('codegouv_label')
+ ->allowEmpty('codegouv_label');
+
+ $validator
+ ->decimal('score')
+ ->allowEmpty('score');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->existsIn(['software_id'], 'Softwares'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\Software;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+use Search\Manager;
+/**
+ * Softwares Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $Licenses
+ * @property \Cake\ORM\Association\HasMany $RelationshipsSoftwaresUsers
+ * @property \Cake\ORM\Association\HasMany $Reviews
+ * @property \Cake\ORM\Association\HasMany $Screenshots
+ * @property \Cake\ORM\Association\HasMany $SoftwaresStatistics
+ * @property \Cake\ORM\Association\BelongsToMany $Relationships
+ */
+class SoftwaresTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('softwares');
+ $this->displayField('softwarename');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+ //For upload file -> avatar
+ $this->addBehavior('Josegonzalez/Upload.Upload', [
+ 'photo' => [
+ 'fields' => [
+ 'dir' => 'logo_directory',
+ ],
+ 'path' => 'files{DS}{model}{DS}{primaryKey}{DS}{field}{DS}avatar',
+ ],
+ ]);
+
+ $this->belongsTo('Licenses', [
+ 'foreignKey' => 'licence_id'
+ ]);
+ $this->hasOne('RawMetricsSoftwares', [
+ 'foreignKey' => 'software_id'
+ ]);
+ $this->hasMany('RelationshipsSoftwaresUsers', [
+ 'foreignKey' => 'software_id'
+ ]);
+ $this->hasMany('Reviews', [
+ 'foreignKey' => 'software_id'
+ ]);
+ $this->hasMany('Screenshots', [
+ 'foreignKey' => 'software_id'
+ ]);
+ $this->hasMany('SoftwaresStatistics', [
+ 'foreignKey' => 'software_id'
+ ]);
+ $this->belongsToMany('Relationships', [
+ 'foreignKey' => 'software_id',
+ 'targetForeignKey' => 'relationship_id',
+ 'joinTable' => 'relationships_softwares'
+ ]);
+
+
+
+ // #######################
+ // ##### For search ######
+ // #######################
+
+ // Add the behaviour to your table
+ $this->addBehavior('Search.Search');
+
+ // Setup search filter using search manager
+ $this->searchManager()
+ ->value('id')
+ // Here we will alias the 'q' query param to search the `Articles.title`
+ // field and the `Articles.content` field, using a LIKE match, with `%`
+ // both before and after.
+ ->add('q', 'Search.Like', [
+ 'before' => true,
+ 'after' => true,
+ 'mode' => 'or',
+ 'comparison' => 'ILIKE',
+ 'wildcardAny' => '*',
+ 'wildcardOne' => '?',
+ 'field' => [$this->aliasField('softwarename'), $this->aliasField('description')]
+ ]);
+// ->add('foo', 'Search.Callback', [
+// 'callback' => function ($query, $args, $filter) {
+// // Modify $query as required
+// }
+// ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('softwarename')
+ ->add('softwarename', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
+
+ $validator
+ ->requirePresence('url_repository', 'create')
+ ->notEmpty('url_repository')
+ ->add('url_repository', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);
+
+ $validator
+ ->allowEmpty('description');
+
+ $validator
+ ->allowEmpty('logo_directory');
+
+ $validator
+ ->allowEmpty('photo');
+
+
+ $validator->add('photo','file',[
+ 'rule' => ['mimeType', ['image/jpeg', 'image/png','image/gif','image/svg+xml']],
+ 'message' => "This format is not allowed"
+ ]);
+
+
+ $validator->provider('uploadImage',new \Josegonzalez\Upload\Validation\ImageValidation());
+
+ //Check that the file is below the maximum height requirement (checked in pixels)
+ $validator->add('photo', 'fileBelowMaxHeight', [
+ 'rule' => ['isBelowMaxHeight', 250],
+ 'message' => 'This image should not be higher than 500px',
+ 'provider' => 'uploadImage'
+ ]);
+
+
+ // Check that the file is Above the minimum height requirement (checked in pixels)
+ $validator->add('photo', 'fileAboveMinHeight', [
+ 'rule' => ['isAboveMinHeight', 100],
+ 'message' => 'This image should at least be 150px high',
+ 'provider' => 'uploadImage'
+ ]);
+
+
+
+ $validator->provider('upload',new \Josegonzalez\Upload\Validation\UploadValidation());
+
+ $validator->add('photo', 'fileBelowMaxSize', [
+ 'rule' => ['isBelowMaxSize', 1000000],
+ 'message' => 'This file is too large',
+ 'provider' => 'upload'
+ ]);
+
+
+
+
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->isUnique(['softwarename']));
+ $rules->add($rules->isUnique(['url_repository']));
+ $rules->add($rules->existsIn(['licence_id'], 'Licenses'));
+ return $rules;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\UserType;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * UserTypes Model
+ *
+ * @property \Cake\ORM\Association\HasMany $Users
+ */
+class UserTypesTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('user_types');
+ $this->displayField('name');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ $this->hasMany('Users', [
+ 'foreignKey' => 'user_type_id'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('name');
+
+ $validator
+ ->allowEmpty('cd');
+
+ return $validator;
+ }
+}
--- /dev/null
+<?php
+namespace App\Model\Table;
+
+use App\Model\Entity\User;
+use Cake\ORM\Query;
+use Cake\ORM\RulesChecker;
+use Cake\ORM\Table;
+use Cake\Validation\Validator;
+
+/**
+ * For authentification
+ */
+use Cake\Auth\DefaultPasswordHasher;
+use Cake\Utility\Text;
+use Cake\Event\Event;
+
+/**
+ * Users Model
+ *
+ * @property \Cake\ORM\Association\BelongsTo $UserTypes
+ * @property \Cake\ORM\Association\HasMany $Reviews
+ * @property \Cake\ORM\Association\BelongsToMany $RelationshipsSoftwares
+ * @property \Cake\ORM\Association\BelongsToMany $Relationships
+ */
+class UsersTable extends Table
+{
+
+ /**
+ * Initialize method
+ *
+ * @param array $config The configuration for the Table.
+ * @return void
+ */
+ public function initialize(array $config)
+ {
+ parent::initialize($config);
+
+ $this->table('users');
+ $this->displayField('username');
+ $this->primaryKey('id');
+
+ $this->addBehavior('Timestamp');
+
+ //For upload file -> avatar
+ $this->addBehavior('Josegonzalez/Upload.Upload', [
+ 'photo' => [
+ 'fields' => [
+ 'dir' => 'logo_directory',
+ ],
+ 'path' => 'webroot{DS}files{DS}{model}{DS}{field}{DS}{primaryKey}{DS}avatar',
+ ],
+ ]);
+
+ $this->belongsTo('UserTypes', [
+ 'foreignKey' => 'user_type_id',
+ 'joinType' => 'INNER'
+ ]);
+ $this->hasMany('Reviews', [
+ 'foreignKey' => 'user_id'
+ ]);
+ $this->belongsToMany('RelationshipsSoftwares', [
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'relationship_id',
+ 'joinTable' => 'relationships_softwares_users'
+ ]);
+ $this->belongsToMany('Relationships', [
+ 'foreignKey' => 'user_id',
+ 'targetForeignKey' => 'recipient_id',
+ 'joinTable' => 'relationships_users'
+ ]);
+ }
+
+ /**
+ * Default validation rules.
+ *
+ * @param \Cake\Validation\Validator $validator Validator instance.
+ * @return \Cake\Validation\Validator
+ */
+ public function validationDefault(Validator $validator)
+ {
+ $validator
+ ->allowEmpty('id', 'create');
+
+ $validator
+ ->allowEmpty('username');
+
+ $validator
+ ->allowEmpty('logo_directory');
+
+ $validator
+ ->allowEmpty('url');
+
+ $validator
+ ->allowEmpty('description');
+
+ $validator
+ ->requirePresence('role', 'create')
+ ->notEmpty('role');
+
+ $validator
+ ->requirePresence('password', 'create')
+ ->notEmpty('password');
+
+ $validator
+ ->add('email', 'valid', ['rule' => 'email'])
+ ->allowEmpty('email');
+
+ $validator
+ ->allowEmpty('photo');
+
+ return $validator;
+ }
+
+ /**
+ * Returns a rules checker object that will be used for validating
+ * application integrity.
+ *
+ * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
+ * @return \Cake\ORM\RulesChecker
+ */
+ public function buildRules(RulesChecker $rules)
+ {
+ $rules->add($rules->isUnique(['username']));
+ $rules->add($rules->isUnique(['email']));
+ $rules->add($rules->existsIn(['user_type_id'], 'UserTypes'));
+ return $rules;
+ }
+
+
+ /**
+ * Before save an user
+ * @param \App\Controller\Api\V1\Event $event
+ * @return boolean
+ */
+ public function beforeSave(Event $event)
+ {
+ $entity = $event->data['entity'];
+
+ if ($entity->isNew()) {
+ $hasher = new DefaultPasswordHasher();
+
+ // Generate an API 'token'
+ $entity->api_key_plain = sha1(Text::uuid());
+
+ // Bcrypt the token so BasicAuthenticate can check
+ // it during login.
+ $entity->api_key = $hasher->hash($entity->api_key_plain);
+ }
+ return true;
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\Fixture;
+
+use Cake\TestSuite\Fixture\TestFixture;
+
+/**
+ * PanelsFixture
+ *
+ */
+class PanelsFixture extends TestFixture
+{
+
+ /**
+ * Fields
+ *
+ * @var array
+ */
+ // @codingStandardsIgnoreStart
+ public $fields = [
+ 'id' => ['type' => 'uuid', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
+ 'request_id' => ['type' => 'uuid', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
+ 'panel' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'title' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'element' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'summary' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'content' => ['type' => 'binary', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ 'unique_panel' => ['type' => 'unique', 'columns' => ['request_id', 'panel'], 'length' => []],
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => '63d116bc-c7fa-441a-8e81-c8abeb35772b',
+ 'request_id' => 'b53d8d94-c964-4f79-8db7-15b21b9d0073',
+ 'panel' => 'Lorem ipsum dolor sit amet',
+ 'title' => 'Lorem ipsum dolor sit amet',
+ 'element' => 'Lorem ipsum dolor sit amet',
+ 'summary' => 'Lorem ipsum dolor sit amet',
+ 'content' => 'Lorem ipsum dolor sit amet'
+ ],
+ ];
+}
--- /dev/null
+<?php
+namespace App\Test\Fixture;
+
+use Cake\TestSuite\Fixture\TestFixture;
+
+/**
+ * RequestsFixture
+ *
+ */
+class RequestsFixture extends TestFixture
+{
+
+ /**
+ * Fields
+ *
+ * @var array
+ */
+ // @codingStandardsIgnoreStart
+ public $fields = [
+ 'id' => ['type' => 'uuid', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
+ 'url' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'content_type' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'status_code' => ['type' => 'integer', 'length' => 10, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'unsigned' => null, 'autoIncrement' => null],
+ 'method' => ['type' => 'string', 'length' => null, 'default' => null, 'null' => true, 'comment' => null, 'precision' => null, 'fixed' => null],
+ 'requested_at' => ['type' => 'timestamp', 'length' => null, 'default' => null, 'null' => false, 'comment' => null, 'precision' => null],
+ '_constraints' => [
+ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
+ ],
+ ];
+ // @codingStandardsIgnoreEnd
+
+ /**
+ * Records
+ *
+ * @var array
+ */
+ public $records = [
+ [
+ 'id' => '806451d3-ddd2-4907-b482-e50dcdbc55f0',
+ 'url' => 'Lorem ipsum dolor sit amet',
+ 'content_type' => 'Lorem ipsum dolor sit amet',
+ 'status_code' => 1,
+ 'method' => 'Lorem ipsum dolor sit amet',
+ 'requested_at' => 1468940036
+ ],
+ ];
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\LicenceTypesTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\LicenceTypesTable Test Case
+ */
+class LicenceTypesTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\LicenceTypesTable
+ */
+ public $LicenceTypes;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.licence_types'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('LicenceTypes') ? [] : ['className' => 'App\Model\Table\LicenceTypesTable'];
+ $this->LicenceTypes = TableRegistry::get('LicenceTypes', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->LicenceTypes);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\LicensesTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\LicensesTable Test Case
+ */
+class LicensesTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\LicensesTable
+ */
+ public $Licenses;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.licenses',
+ 'app.licence_types'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Licenses') ? [] : ['className' => 'App\Model\Table\LicensesTable'];
+ $this->Licenses = TableRegistry::get('Licenses', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Licenses);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\PanelsTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\PanelsTable Test Case
+ */
+class PanelsTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\PanelsTable
+ */
+ public $Panels;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.panels',
+ 'app.requests'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Panels') ? [] : ['className' => 'App\Model\Table\PanelsTable'];
+ $this->Panels = TableRegistry::get('Panels', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Panels);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RelationshipTypesTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RelationshipTypesTable Test Case
+ */
+class RelationshipTypesTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RelationshipTypesTable
+ */
+ public $RelationshipTypes;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.relationship_types',
+ 'app.relationships'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('RelationshipTypes') ? [] : ['className' => 'App\Model\Table\RelationshipTypesTable'];
+ $this->RelationshipTypes = TableRegistry::get('RelationshipTypes', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->RelationshipTypes);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RelationshipsSoftwaresTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RelationshipsSoftwaresTable Test Case
+ */
+class RelationshipsSoftwaresTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RelationshipsSoftwaresTable
+ */
+ public $RelationshipsSoftwares;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.relationships_softwares',
+ 'app.softwares',
+ 'app.relationships',
+ 'app.relationship_types',
+ 'app.relationships_softwares_users',
+ 'app.users',
+ 'app.relationships_users'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('RelationshipsSoftwares') ? [] : ['className' => 'App\Model\Table\RelationshipsSoftwaresTable'];
+ $this->RelationshipsSoftwares = TableRegistry::get('RelationshipsSoftwares', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->RelationshipsSoftwares);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RelationshipsSoftwaresUsersTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RelationshipsSoftwaresUsersTable Test Case
+ */
+class RelationshipsSoftwaresUsersTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RelationshipsSoftwaresUsersTable
+ */
+ public $RelationshipsSoftwaresUsers;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.relationships_softwares_users',
+ 'app.softwares',
+ 'app.users',
+ 'app.relationships',
+ 'app.relationship_types',
+ 'app.relationships_softwares',
+ 'app.relationships_users'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('RelationshipsSoftwaresUsers') ? [] : ['className' => 'App\Model\Table\RelationshipsSoftwaresUsersTable'];
+ $this->RelationshipsSoftwaresUsers = TableRegistry::get('RelationshipsSoftwaresUsers', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->RelationshipsSoftwaresUsers);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RelationshipsTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RelationshipsTable Test Case
+ */
+class RelationshipsTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RelationshipsTable
+ */
+ public $Relationships;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.relationships',
+ 'app.relationship_types',
+ 'app.relationships_softwares_users',
+ 'app.softwares',
+ 'app.relationships_softwares',
+ 'app.users',
+ 'app.relationships_users'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Relationships') ? [] : ['className' => 'App\Model\Table\RelationshipsTable'];
+ $this->Relationships = TableRegistry::get('Relationships', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Relationships);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RelationshipsUsersTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RelationshipsUsersTable Test Case
+ */
+class RelationshipsUsersTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RelationshipsUsersTable
+ */
+ public $RelationshipsUsers;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.relationships_users',
+ 'app.users',
+ 'app.relationships',
+ 'app.relationship_types',
+ 'app.relationships_softwares_users',
+ 'app.softwares',
+ 'app.relationships_softwares'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('RelationshipsUsers') ? [] : ['className' => 'App\Model\Table\RelationshipsUsersTable'];
+ $this->RelationshipsUsers = TableRegistry::get('RelationshipsUsers', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->RelationshipsUsers);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\RequestsTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\RequestsTable Test Case
+ */
+class RequestsTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\RequestsTable
+ */
+ public $Requests;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.requests',
+ 'app.panels'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Requests') ? [] : ['className' => 'App\Model\Table\RequestsTable'];
+ $this->Requests = TableRegistry::get('Requests', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Requests);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\ReviewsTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\ReviewsTable Test Case
+ */
+class ReviewsTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\ReviewsTable
+ */
+ public $Reviews;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.reviews',
+ 'app.users',
+ 'app.softwares'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Reviews') ? [] : ['className' => 'App\Model\Table\ReviewsTable'];
+ $this->Reviews = TableRegistry::get('Reviews', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Reviews);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\ScreenshotsTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\ScreenshotsTable Test Case
+ */
+class ScreenshotsTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\ScreenshotsTable
+ */
+ public $Screenshots;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.screenshots',
+ 'app.softwares'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Screenshots') ? [] : ['className' => 'App\Model\Table\ScreenshotsTable'];
+ $this->Screenshots = TableRegistry::get('Screenshots', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Screenshots);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\SoftwaresTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\SoftwaresTable Test Case
+ */
+class SoftwaresTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\SoftwaresTable
+ */
+ public $Softwares;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.softwares',
+ 'app.licenses',
+ 'app.licence_types',
+ 'app.raw_metrics_softwares',
+ 'app.relationships_softwares_users',
+ 'app.users',
+ 'app.relationships',
+ 'app.relationship_types',
+ 'app.relationships_softwares',
+ 'app.relationships_users',
+ 'app.reviews',
+ 'app.screenshots',
+ 'app.softwares_statistics'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('Softwares') ? [] : ['className' => 'App\Model\Table\SoftwaresTable'];
+ $this->Softwares = TableRegistry::get('Softwares', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->Softwares);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test buildRules method
+ *
+ * @return void
+ */
+ public function testBuildRules()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}
--- /dev/null
+<?php
+namespace App\Test\TestCase\Model\Table;
+
+use App\Model\Table\UserTypesTable;
+use Cake\ORM\TableRegistry;
+use Cake\TestSuite\TestCase;
+
+/**
+ * App\Model\Table\UserTypesTable Test Case
+ */
+class UserTypesTableTest extends TestCase
+{
+
+ /**
+ * Test subject
+ *
+ * @var \App\Model\Table\UserTypesTable
+ */
+ public $UserTypes;
+
+ /**
+ * Fixtures
+ *
+ * @var array
+ */
+ public $fixtures = [
+ 'app.user_types',
+ 'app.users'
+ ];
+
+ /**
+ * setUp method
+ *
+ * @return void
+ */
+ public function setUp()
+ {
+ parent::setUp();
+ $config = TableRegistry::exists('UserTypes') ? [] : ['className' => 'App\Model\Table\UserTypesTable'];
+ $this->UserTypes = TableRegistry::get('UserTypes', $config);
+ }
+
+ /**
+ * tearDown method
+ *
+ * @return void
+ */
+ public function tearDown()
+ {
+ unset($this->UserTypes);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test initialize method
+ *
+ * @return void
+ */
+ public function testInitialize()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+
+ /**
+ * Test validationDefault method
+ *
+ * @return void
+ */
+ public function testValidationDefault()
+ {
+ $this->markTestIncomplete('Not implemented yet.');
+ }
+}