Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gredu_labs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
itminedu
gredu_labs
Commits
6d502102
Commit
6d502102
authored
Mar 16, 2016
by
Vassilis Kanellopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use map to find assets from inventory
parent
225b1ac3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
5 deletions
+40
-5
config/settings/inventory.local.php.dist
config/settings/inventory.local.php.dist
+22
-0
module/sch_sync/bootstrap.php
module/sch_sync/bootstrap.php
+6
-1
module/sch_sync/src/Middleware/CreateLabs.php
module/sch_sync/src/Middleware/CreateLabs.php
+11
-3
module/schools/data/schema.mysql.sql
module/schools/data/schema.mysql.sql
+1
-1
No files found.
config/settings/inventory.local.php.dist
View file @
6d502102
<?php
return
[
'inventory'
=>
[
'base_uri'
=>
''
,
'category_map'
=>
[
// form inventory => in database
'ACCESS POINT'
=>
'ACCESS POINT'
,
'LAPTOP'
=>
'LAPTOP'
,
'MODEM / ROUTER'
=>
'MODEM / ROUTER'
,
'PATCH PANEL'
=>
'PATCH PANEL'
,
'PRINTER'
=>
'PRINTER'
,
'RACK'
=>
'RACK'
,
'SCANNER'
=>
'SCANNER'
,
'SERVER'
=>
'SERVER'
,
'SWITCH/ HUB'
=>
'SWITCH/ HUB'
,
'TABLET'
=>
'TABLET'
,
'WEBCAM'
=>
'WEBCAM'
,
'WORKSTATION'
=>
'ΣΤΑΘΜΟΣ ΕΡΓΑΣΙΑΣ'
,
'ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ'
=>
'ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ'
,
'ΔΙΑΔΡΑΣΤΙΚΟ ΣΥΣΤΗΜΑ'
=>
'ΔΙΑΔΡΑΣΤΙΚΟ ΣΥΣΤΗΜΑ'
,
'ΕΠΕΞΕΡΓΑΣΤΗΣ (CPU)'
=>
'ΕΠΕΞΕΡΓΑΣΤΗΣ (CPU)'
,
'ΚΙΝΗΤΟ ΕΡΓΑΣΤΗΡΙΟ'
=>
'ΚΙΝΗΤΟ ΕΡΓΑΣΤΗΡΙΟ'
,
'ΜΝΗΜΗ RAM'
=>
'ΜΝΗΜΗ RAM'
,
'ΟΘΟΝΗ'
=>
'ΟΘΟΝΗ'
,
'ΣΚΛΗΡΟΣ ΔΙΣΚΟΣ'
=>
'ΣΚΛΗΡΟΣ ΔΙΣΚΟΣ'
,
],
],
];
\ No newline at end of file
module/sch_sync/bootstrap.php
View file @
6d502102
...
...
@@ -51,13 +51,18 @@ return function (App $app) {
);
};
$container
[
CreateLabs
::
class
]
=
function
(
$c
)
{
$settings
=
$c
->
get
(
'settings'
);
$categoryMap
=
isset
(
$settings
[
'inventory'
][
'category_map'
])
?
$settings
[
'inventory'
][
'category_map'
]
:
[];
return
new
CreateLabs
(
$c
->
get
(
LabServiceInterface
::
class
),
$c
->
get
(
AssetServiceInterface
::
class
),
$c
->
get
(
'SchInventory\\Service'
),
$c
->
get
(
SchoolServiceInterface
::
class
),
$c
->
get
(
'authentication_service'
),
$c
->
get
(
'logger'
)
$c
->
get
(
'logger'
),
$categoryMap
);
};
});
...
...
module/sch_sync/src/Middleware/CreateLabs.php
View file @
6d502102
...
...
@@ -58,13 +58,20 @@ class CreateLabs
*/
private
$logger
;
/**
*
* @var array
*/
private
$categoryMap
;
public
function
__construct
(
LabServiceInterface
$labService
,
AssetServiceInterface
$assetService
,
InventoryService
$inventoryService
,
SchoolServiceInterface
$schoolService
,
AuthenticationServiceInterface
$authService
,
LoggerInterface
$logger
LoggerInterface
$logger
,
array
$categoryMap
=
[]
)
{
$this
->
labService
=
$labService
;
$this
->
assetService
=
$assetService
;
...
...
@@ -72,6 +79,7 @@ class CreateLabs
$this
->
schoolService
=
$schoolService
;
$this
->
authService
=
$authService
;
$this
->
logger
=
$logger
;
$this
->
categoryMap
=
$categoryMap
;
}
public
function
__invoke
(
Request
$req
,
Response
$res
,
callable
$next
)
...
...
@@ -134,10 +142,10 @@ class CreateLabs
$categoryName
=
$item
[
'item_template.category.name'
];
$type
=
reset
(
array_filter
(
array_keys
(
$
assetTypes
),
function
(
$type
)
use
(
$categoryName
)
{
$type
=
reset
(
array_filter
(
array_keys
(
$
this
->
categoryMap
),
function
(
$type
)
use
(
$categoryName
)
{
return
$type
==
$categoryName
;
}));
$type
=
(
$type
)
?
$assetTypes
[
$t
ype
]
:
false
;
$type
=
(
$type
)
?
$assetTypes
[
$t
his
->
categoryMap
[
$type
]
]
:
false
;
if
(
$type
!==
false
)
{
if
(
!
isset
(
$uniq
[
$item
[
'location.id'
]]
->
ownSchoolAsset
[
$type
]))
{
...
...
module/schools/data/schema.mysql.sql
View file @
6d502102
...
...
@@ -108,7 +108,7 @@ CREATE TABLE `itemcategory` (
LOCK
TABLES
`itemcategory`
WRITE
;
/*!40000 ALTER TABLE `itemcategory` DISABLE KEYS */
;
INSERT
INTO
`itemcategory`
VALUES
(
8
,
'ACCESS POINT'
),(
26
,
'LAPTOP'
),(
6
,
'MODEM / ROUTER '
),(
5
,
'PATCH PANEL'
),(
14
,
'PRINTER'
),(
3
,
'RACK'
),(
13
,
'SCANNER'
),(
24
,
'SERVER'
),(
2
,
'SWITCH/ HUB'
),(
23
,
'TABLET'
),(
11
,
'WEBCAM'
),(
22
,
'
WORKSTATION'
),(
41
,
'ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ'
),(
40
,
'ΔΙΑΔΡΑΣΤΙΚΟ ΣΥΣΤΗΜΑ'
),(
38
,
'ΕΠΕΞΕΡΓΑΣΤΗΣ (CPU)'
),(
34
,
'ΚΙΝΗΤΟ ΕΡΓΑΣΤΗΡΙΟ'
),(
32
,
'ΜΝΗΜΗ RAM'
),(
30
,
'ΟΘΟΝΗ'
),(
29
,
'ΣΚΛΗΡΟΣ ΔΙΣΚΟΣ
'
);
INSERT
INTO
`itemcategory`
VALUES
(
8
,
'ACCESS POINT'
),(
26
,
'LAPTOP'
),(
6
,
'MODEM / ROUTER '
),(
5
,
'PATCH PANEL'
),(
14
,
'PRINTER'
),(
3
,
'RACK'
),(
13
,
'SCANNER'
),(
24
,
'SERVER'
),(
2
,
'SWITCH/ HUB'
),(
23
,
'TABLET'
),(
11
,
'WEBCAM'
),(
22
,
'
ΣΤΑΘΜΟΣ ΕΡΓΑΣΙΑΣ'
),(
41
,
'ΒΙΝΤΕΟΠΡΟΒΟΛΕΑΣ'
),(
40
,
'ΔΙΑΔΡΑΣΤΙΚΟ ΣΥΣΤΗΜΑ'
),(
38
,
'ΕΠΕΞΕΡΓΑΣΤΗΣ (CPU)'
),(
34
,
'ΚΙΝΗΤΟ ΕΡΓΑΣΤΗΡΙΟ'
),(
32
,
'ΜΝΗΜΗ RAM'
),(
30
,
'ΟΘΟΝΗ'
),(
29
,
'ΣΚΛΗΡΟΣ ΔΙΣΚΟΣ'
),(
42
,
'ΤΡΙΣΔΙΑΣΤΑΤΟΣ ΕΚΤΥΠΩΤΗΣ'
),(
43
,
'ΤΡΙΣΔΙΑΣΤΑΤΟΣ ΣΑΡΩΤΗΣ'
),(
44
,
'ΣΕΤ ΡΟΜΠΟΤΙΚΗΣ - ΑΙΣΘΗΤΗΡΩΝ'
),(
45
,
'ΔΟΜΗΜΕΝΗ ΚΑΛΩΔΙΩΣΗ
'
);
/*!40000 ALTER TABLE `itemcategory` ENABLE KEYS */
;
UNLOCK
TABLES
;
...
...
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