Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Σταύρος Παπαδάκης
gredu_labs
Commits
771a9617
Commit
771a9617
authored
Feb 22, 2016
by
Georgios Tsakalos
Browse files
add software service interface and implementation
update school schema remove software methods from asset service
parent
ea769530
Changes
5
Hide whitespace changes
Inline
Side-by-side
module/schools/data/schema.mysql.sql
View file @
771a9617
...
...
@@ -418,6 +418,131 @@ LOCK TABLES `teacher` WRITE;
/*!40000 ALTER TABLE `teacher` DISABLE KEYS */
;
/*!40000 ALTER TABLE `teacher` ENABLE KEYS */
;
UNLOCK
TABLES
;
--
-- Table structure for table `lesson`
--
DROP
TABLE
IF
EXISTS
`lesson`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`lesson`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `lab`
--
DROP
TABLE
IF
EXISTS
`lab`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`lab`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`type`
int
(
11
)
unsigned
DEFAULT
NULL
,
`area`
int
(
11
)
unsigned
DEFAULT
NULL
,
`use_ext_program`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`use_in_program`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`attachment`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`has_network`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`has_server`
tinyint
(
1
)
unsigned
DEFAULT
NULL
,
`school_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
`teacher_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
KEY
`index_foreignkey_lab_school`
(
`school_id`
),
KEY
`index_foreignkey_lab_teacher`
(
`teacher_id`
),
CONSTRAINT
`c_fk_lab_school_id`
FOREIGN
KEY
(
`school_id`
)
REFERENCES
`school`
(
`id`
)
ON
DELETE
SET
NULL
ON
UPDATE
SET
NULL
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
2
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `lesson_lab`
--
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`lab_lesson`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`lesson_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
`lab_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`UQ_82ac3a020f1d21984f224331fbd99880f89b2e71`
(
`lab_id`
,
`lesson_id`
),
KEY
`index_foreignkey_lab_lesson_lesson`
(
`lesson_id`
),
KEY
`index_foreignkey_lab_lesson_lab`
(
`lab_id`
),
CONSTRAINT
`c_fk_lab_lesson_lab_id`
FOREIGN
KEY
(
`lab_id`
)
REFERENCES
`lab`
(
`id`
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
,
CONSTRAINT
`c_fk_lab_lesson_lesson_id`
FOREIGN
KEY
(
`lesson_id`
)
REFERENCES
`lesson`
(
`id`
)
ON
DELETE
CASCADE
ON
UPDATE
CASCADE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
9
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `softwarecategory`
--
DROP
TABLE
IF
EXISTS
`softwarecategory`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`softwarecategory`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`name`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
3
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
--
-- Table structure for table `schoolasset`
--
DROP
TABLE
IF
EXISTS
`schoolasset`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`schoolasset`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`itemcategory_id`
int
(
11
)
unsigned
NOT
NULL
,
`school_id`
int
(
11
)
unsigned
NOT
NULL
,
`qty`
int
(
11
)
unsigned
NOT
NULL
,
`lab_id`
int
(
11
)
unsigned
NOT
NULL
,
`acquisition_year`
char
(
4
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`comments`
text
COLLATE
utf8mb4_unicode_ci
,
PRIMARY
KEY
(
`id`
),
KEY
`index_foreignkey_schoolasset_itemcategory`
(
`itemcategory_id`
),
KEY
`index_foreignkey_schoolasset_school`
(
`school_id`
),
KEY
`index_foreignkey_schoolasset_lab`
(
`lab_id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
--
-- Table structure for table `schoolasset`
--
DROP
TABLE
IF
EXISTS
`software`
;
/*!40101 SET @saved_cs_client = @@character_set_client */
;
/*!40101 SET character_set_client = utf8 */
;
CREATE
TABLE
`software`
(
`id`
int
(
11
)
unsigned
NOT
NULL
AUTO_INCREMENT
,
`softwarecategory_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
`school_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
`lab_id`
int
(
11
)
unsigned
DEFAULT
NULL
,
`title`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`vendor`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
`url`
varchar
(
191
)
COLLATE
utf8mb4_unicode_ci
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
KEY
`index_foreignkey_software_softwarecategory`
(
`softwarecategory_id`
),
KEY
`index_foreignkey_software_school`
(
`school_id`
),
CONSTRAINT
`c_fk_software_lab_id`
FOREIGN
KEY
(
`lab_id`
)
REFERENCES
`lab`
(
`id`
)
ON
DELETE
SET
NULL
ON
UPDATE
SET
NULL
,
CONSTRAINT
`c_fk_software_school_id`
FOREIGN
KEY
(
`school_id`
)
REFERENCES
`school`
(
`id`
)
ON
DELETE
SET
NULL
ON
UPDATE
SET
NULL
,
CONSTRAINT
`c_fk_software_softwarecategory_id`
FOREIGN
KEY
(
`softwarecategory_id`
)
REFERENCES
`softwarecategory`
(
`id`
)
ON
DELETE
SET
NULL
ON
UPDATE
SET
NULL
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
2
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
/*!40101 SET character_set_client = @saved_cs_client */
;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */
;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */
;
...
...
@@ -426,4 +551,4 @@ UNLOCK TABLES;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */
;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
\ No newline at end of file
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */
;
module/schools/src/Service/AssetService.php
View file @
771a9617
...
...
@@ -40,10 +40,6 @@ class AssetService implements AssetServiceInterface, SchoolAssetsInterface
return
$this
->
exportItemCategory
(
$category
);
}
public
function
createSoftwareCategory
(
array
$data
)
{
}
public
function
findItemCategoryByName
(
$name
)
{
$category
=
R
::
findOne
(
'itemcategory'
,
'name = ?'
,
[
$name
]);
...
...
@@ -54,10 +50,6 @@ class AssetService implements AssetServiceInterface, SchoolAssetsInterface
return
;
}
public
function
findSoftwareCategoryByName
(
$name
)
{
}
public
function
getAllItemCategories
()
{
return
array_values
(
array_map
(
...
...
@@ -66,10 +58,6 @@ class AssetService implements AssetServiceInterface, SchoolAssetsInterface
));
}
public
function
getAllSoftwareCategories
()
{
}
public
function
getItemCategoryById
(
$id
)
{
$category
=
R
::
load
(
'itemcategory'
,
$id
);
...
...
@@ -80,14 +68,6 @@ class AssetService implements AssetServiceInterface, SchoolAssetsInterface
return
$this
->
exportItemCategory
(
$category
);
}
public
function
getSoftwareCategoryById
(
$id
)
{
}
public
function
updateSoftwareCategory
(
$id
,
array
$data
)
{
}
public
function
getAssetsForSchool
(
$school_id
,
array
$filters
=
[])
{
$sql
=
[
' school_id = ? '
];
...
...
module/schools/src/Service/AssetServiceInterface.php
View file @
771a9617
...
...
@@ -17,11 +17,5 @@ interface AssetServiceInterface
public
function
findItemCategoryByName
(
$name
);
public
function
getItemCategoryById
(
$id
);
public
function
createSoftwareCategory
(
array
$data
);
public
function
updateSoftwareCategory
(
$id
,
array
$data
);
public
function
getAllSoftwareCategories
();
public
function
findSoftwareCategoryByName
(
$name
);
public
function
getSoftwareCategoryById
(
$id
);
public
function
createExistingItem
(
array
$data
);
}
module/schools/src/Service/SoftwareService.php
0 → 100644
View file @
771a9617
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Service
;
use
InvalidArgumentException
;
use
RedBeanPHP\R
;
class
SoftwareService
implements
SoftwareServiceInterface
{
public
function
createSoftwareCategory
(
$name
)
{
$software_category
=
R
::
dispense
(
'softwarecategory'
);
$software_category
->
name
=
$name
;
R
::
store
(
$software_category
);
}
public
function
getSoftwareCategoryById
(
$id
)
{
$software_category
=
R
::
load
(
'softwarecategory'
,
$id
);
return
$software_category
->
export
();
}
public
function
getSoftwareCategories
()
{
$software_categories
=
R
::
findAll
(
'softwarecategory'
);
return
$software_categories
;
}
public
function
updateSoftwareCategory
(
$id
,
$data
)
{
$software_category
=
R
::
load
(
'softwarecategory'
);
$software_category
->
name
=
$name
;
R
::
store
(
$software_category
);
}
public
function
createSoftware
(
array
$data
)
{
unset
(
$data
[
'id'
]);
$software
=
R
::
dispense
(
'software'
);
$this
->
persistSoftware
(
$software
,
$data
);
return
$software
->
export
();
}
public
function
updateSoftware
(
array
$data
,
$id
)
{
$software
=
R
::
load
(
'software'
,
$id
);
if
(
!
$software
->
id
)
{
throw
new
\
InvalidArgumentException
(
'No software found'
);
}
$this
->
persistSoftware
(
$software
,
$id
);
return
$software
->
export
();
}
private
function
persistSoftware
(
$software
,
array
$data
)
{
$software
->
softwarecategory_id
=
$data
[
'softwarecategory'
];
$software
->
school_id
=
$data
[
'school_id'
];
$software
->
lab_id
=
$data
[
'lab_id'
];
$software
->
title
=
$data
[
'title'
];
$software
->
vendor
=
$data
[
'vendor'
];
$software
->
url
=
$data
[
'url'
];
R
::
store
(
$software
);
}
public
function
getSoftwareById
(
$id
)
{
$software
=
R
::
load
(
'software'
,
$id
);
return
$software
->
export
();
}
public
function
getSoftwareBySchoolId
(
$id
)
{
$software
=
R
::
findAll
(
'software'
,
'school_id = ?'
,
[
$id
]);
return
$software
->
exportAll
();
}
public
function
getSoftwareByLabId
(
$id
)
{
$software
=
R
::
findAll
(
'software'
,
'lab_id = ?'
,
[
$id
]);
return
$software
->
exportAll
();
}
}
module/schools/src/Service/SoftwareServiceInterface.php
0 → 100644
View file @
771a9617
<?php
/**
* gredu_labs
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace
GrEduLabs\Schools\Service
;
interface
SoftwareServiceInterface
{
public
function
createSoftwareCategory
(
$name
);
public
function
getSoftwareCategoryById
(
$id
);
public
function
getSoftwareCagegories
();
public
function
updateSoftwareCategory
(
$id
,
$data
);
public
function
createSoftware
(
array
$data
);
public
function
updateSoftware
(
array
$data
,
$id
);
public
function
getSoftwareById
(
$id
);
public
function
getSoftwareBySchoolId
(
$id
);
public
function
getSoftwareByLabId
(
$id
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment