Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
blendb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
C3SL
blendb
Commits
1d1ad135
Commit
1d1ad135
authored
6 years ago
by
Rafael Dias
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#80
: Add enumHandler
Signed-off-by:
Rafael
<
rpd17@inf.ufpr.br
>
parent
6f4d8d18
No related branches found
No related tags found
No related merge requests found
Pipeline
#16886
passed
6 years ago
Stage: test
Stage: build
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/core/dimension.ts
+3
-3
3 additions, 3 deletions
src/core/dimension.ts
src/core/source.ts
+3
-2
3 additions, 2 deletions
src/core/source.ts
src/util/configParser.ts
+3
-2
3 additions, 2 deletions
src/util/configParser.ts
src/util/enumHandler.ts
+48
-0
48 additions, 0 deletions
src/util/enumHandler.ts
with
57 additions
and
7 deletions
src/core/dimension.ts
+
3
−
3
View file @
1d1ad135
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
*/
*/
import
{
RelationType
,
DataType
}
from
"
../common/types
"
;
import
{
RelationType
,
DataType
}
from
"
../common/types
"
;
import
{
Enum
Type
}
from
"
.
/enumType
"
;
import
{
Enum
Handler
}
from
"
.
./util/enumHandler
"
;
/** Parameters used to create a Dimension object. */
/** Parameters used to create a Dimension object. */
export
interface
DimensionOptions
{
export
interface
DimensionOptions
{
...
@@ -96,14 +96,14 @@ export class Dimension {
...
@@ -96,14 +96,14 @@ export class Dimension {
if
(
this
.
relation
===
RelationType
.
NONE
)
{
if
(
this
.
relation
===
RelationType
.
NONE
)
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
dataType
:
(
this
.
dataType
!==
DataType
.
NONE
)
?
EnumType
.
stringfy
DataType
(
this
.
dataType
)
:
this
.
enumType
,
dataType
:
EnumHandler
.
select
DataType
(
this
.
dataType
,
this
.
enumType
)
,
description
:
this
.
description
description
:
this
.
description
};
};
}
}
else
{
else
{
return
{
return
{
name
:
this
.
name
,
name
:
this
.
name
,
dataType
:
(
this
.
dataType
!==
DataType
.
NONE
)
?
EnumType
.
stringfy
DataType
(
this
.
dataType
)
:
this
.
enumType
,
dataType
:
EnumHandler
.
select
DataType
(
this
.
dataType
,
this
.
enumType
)
,
parent
:
this
.
parent
.
name
,
parent
:
this
.
parent
.
name
,
relation
:
Dimension
.
stringifyRelationType
(
this
.
relation
),
relation
:
Dimension
.
stringifyRelationType
(
this
.
relation
),
description
:
this
.
description
description
:
this
.
description
...
...
This diff is collapsed.
Click to expand it.
src/core/source.ts
+
3
−
2
View file @
1d1ad135
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
import
{
EnumType
}
from
"
./enumType
"
;
import
{
EnumType
}
from
"
./enumType
"
;
import
{
DataType
}
from
"
../common/types
"
;
import
{
DataType
}
from
"
../common/types
"
;
import
{
EnumHandler
}
from
"
../util/enumHandler
"
;
/** Attribute of a source. */
/** Attribute of a source. */
export
interface
Field
{
export
interface
Field
{
...
@@ -121,7 +122,7 @@ export class Source {
...
@@ -121,7 +122,7 @@ export class Source {
return
{
return
{
name
:
i
.
name
,
name
:
i
.
name
,
description
:
i
.
description
,
description
:
i
.
description
,
dataType
:
(
i
.
dataType
!==
DataType
.
NONE
)
?
EnumType
.
stringfy
DataType
(
i
.
dataType
)
:
i
.
enumType
dataType
:
EnumHandler
.
select
DataType
(
i
.
dataType
,
i
.
enumType
)
};
};
});
});
return
str
;
return
str
;
...
@@ -138,7 +139,7 @@ export class Source {
...
@@ -138,7 +139,7 @@ export class Source {
name
:
i
.
name
,
name
:
i
.
name
,
description
:
i
.
description
,
description
:
i
.
description
,
dataType
:
EnumType
.
parseDataType
(
i
.
dataType
),
dataType
:
EnumType
.
parseDataType
(
i
.
dataType
),
enumType
:
(
Enum
Type
.
parseDataType
(
i
.
dataType
)
===
DataType
.
NONE
)
?
i
.
dataType
:
""
enumType
:
Enum
Handler
.
selectEnumType
(
i
.
dataType
)
};
};
});
});
return
str
;
return
str
;
...
...
This diff is collapsed.
Click to expand it.
src/util/configParser.ts
+
3
−
2
View file @
1d1ad135
...
@@ -22,6 +22,7 @@ import { Metric, MetricOptions, MetricStrOptions } from "../core/metric";
...
@@ -22,6 +22,7 @@ import { Metric, MetricOptions, MetricStrOptions } from "../core/metric";
import
{
Dimension
,
DimensionOptions
,
DimensionStrOptions
}
from
"
../core/dimension
"
;
import
{
Dimension
,
DimensionOptions
,
DimensionStrOptions
}
from
"
../core/dimension
"
;
import
{
View
,
ViewOptions
,
LoadView
}
from
"
../core/view
"
;
import
{
View
,
ViewOptions
,
LoadView
}
from
"
../core/view
"
;
import
{
EnumType
,
EnumTypeOptions
}
from
"
../core/enumType
"
;
import
{
EnumType
,
EnumTypeOptions
}
from
"
../core/enumType
"
;
import
{
EnumHandler
}
from
"
./enumHandler
"
;
import
{
RelationType
,
DataType
}
from
"
../common/types
"
;
import
{
RelationType
,
DataType
}
from
"
../common/types
"
;
import
{
Opcode
}
from
"
../common/expression
"
;
import
{
Opcode
}
from
"
../common/expression
"
;
import
{
Filter
}
from
"
../core/filter
"
;
import
{
Filter
}
from
"
../core/filter
"
;
...
@@ -334,7 +335,7 @@ export class ConfigParser {
...
@@ -334,7 +335,7 @@ export class ConfigParser {
description
:
opts
.
description
,
description
:
opts
.
description
,
parent
:
dims
[
i
],
parent
:
dims
[
i
],
relation
:
Dimension
.
parseRelationType
(
opts
.
relation
),
relation
:
Dimension
.
parseRelationType
(
opts
.
relation
),
enumType
:
(
Enum
Type
.
parseData
Type
(
opts
.
dataType
)
===
DataType
.
NONE
)
?
opts
.
dataType
:
""
enumType
:
Enum
Handler
.
selectEnum
Type
(
opts
.
dataType
)
};
};
}
}
}
}
...
@@ -347,7 +348,7 @@ export class ConfigParser {
...
@@ -347,7 +348,7 @@ export class ConfigParser {
description
:
opts
.
description
,
description
:
opts
.
description
,
parent
:
null
,
parent
:
null
,
relation
:
RelationType
.
NONE
,
relation
:
RelationType
.
NONE
,
enumType
:
(
Enum
Type
.
parseData
Type
(
opts
.
dataType
)
===
DataType
.
NONE
)
?
opts
.
dataType
:
""
enumType
:
Enum
Handler
.
selectEnum
Type
(
opts
.
dataType
)
};
};
}
}
...
...
This diff is collapsed.
Click to expand it.
src/util/enumHandler.ts
0 → 100644
+
48
−
0
View file @
1d1ad135
import
{
DataType
}
from
"
../common/types
"
;
/*
* Copyright (C) 2018 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana
*
* This file is part of blendb.
*
* blendb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* blendb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with blendb. If not, see <http://www.gnu.org/licenses/>.
*/
import
{
EnumType
}
from
"
../core/enumType
"
;
/**
* Enum's handler. Manage changes between
* string , datatype and enumtype.
*/
export
class
EnumHandler
{
/**
* Checks if it's a valid datatype, otherwise will be an enumtype
* @param dt datatype to compare, used as return if comparation succeed
* @param en enumtype as return if comparation fails
*/
public
static
selectDataType
(
dt
:
DataType
,
en
:
string
):
string
{
return
(
dt
!==
DataType
.
NONE
)
?
EnumType
.
stringfyDataType
(
dt
)
:
en
;
}
/**
* Checks if it's a valid datatype, otherwise return an empity string
* @param data datatype to compare, used as return if comparation succeed
*/
public
static
selectEnumType
(
dt
:
string
):
string
{
return
(
EnumType
.
parseDataType
(
dt
)
===
DataType
.
NONE
)
?
dt
:
""
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment