Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cis-workflow-gen
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
msc
cis-workflow-gen
Commits
34a875db
There was an error fetching the commit references. Please try again later.
Commit
34a875db
authored
4 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
allow explicit argument and ignore argument
parent
816e66b2
No related branches found
No related tags found
1 merge request
!1
Allow explicit arg
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
activity.hpp
+52
-17
52 additions, 17 deletions
activity.hpp
utility.hpp
+11
-1
11 additions, 1 deletion
utility.hpp
xaml-template.hpp
+15
-6
15 additions, 6 deletions
xaml-template.hpp
xaml.gen.example.cc
+5
-1
5 additions, 1 deletion
xaml.gen.example.cc
with
83 additions
and
25 deletions
activity.hpp
+
52
−
17
View file @
34a875db
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include
<queue>
#include
<queue>
#include
<algorithm>
#include
<algorithm>
#include
"u
uid
.hpp"
#include
"u
tility
.hpp"
#include
"xaml-template.hpp"
#include
"xaml-template.hpp"
#include
<rlib/string.hpp>
#include
<rlib/string.hpp>
#include
<rlib/require/cxx14>
#include
<rlib/require/cxx14>
...
@@ -24,39 +24,74 @@ namespace CIS {
...
@@ -24,39 +24,74 @@ namespace CIS {
class
Activity
{
class
Activity
{
public:
public:
friend
Flow
;
friend
Flow
;
// All `Name` should not contain QuotationMark(")
Activity
(
string
displayName
,
string
className
,
string
entityName
=
""
)
Activity
(
string
displayName
,
string
className
,
string
entityName
=
""
)
:
displayName
(
displayName
),
className
(
className
),
entityName
(
entityName
),
taskId
(
GenUUID
())
{}
:
displayName
(
Utility
::
HtmlEscapeString
(
displayName
)
)
,
className
(
className
),
entityName
(
entityName
),
taskId
(
Utility
::
GenUUID
())
{}
Flow
operator
>>
(
const
Flow
&
seqNext
)
const
;
Flow
operator
>>
(
const
Flow
&
seqNext
)
const
;
Flow
operator
|
(
const
Flow
&
seqNext
)
const
;
Flow
operator
|
(
const
Flow
&
seqNext
)
const
;
void
addInputSetting
(
string
k
,
string
v
)
{
void
addInputSetting
(
string
k
,
string
v
)
{
inputSettings
[
k
]
=
v
;
inputSettings
[
k
]
=
v
;
}
}
void
addRawActivityArgument
(
string
xamlTypeString
,
string
csharpValueCode
)
{
void
explicitSetRawArgument
(
string
argTypeInXaml
,
string
argValueInCSharp
)
{
throw
std
::
invalid_argument
(
"Not implemented yet."
);
explicitArgType
=
argTypeInXaml
;
explicitArgValue
=
argValueInCSharp
;
}
}
private
:
private
:
string
displayName
,
className
,
entityName
;
string
displayName
,
className
,
entityName
;
string
taskId
;
string
taskId
;
std
::
unordered_map
<
string
,
string
>
inputSettings
;
std
::
unordered_map
<
string
,
string
>
inputSettings
;
string
explicitArgType
,
explicitArgValue
;
auto
inputSettingsToCodelines
()
const
{
// Convert InputSettings Dictionary to C# code.
std
::
list
<
string
>
inputSettingStrings
;
std
::
transform
(
this
->
inputSettings
.
begin
(),
this
->
inputSettings
.
end
(),
std
::
back_inserter
(
inputSettingStrings
),
[](
auto
&&
kv
)
{
return
" {
\"
{}
\"
,
\"
{}
\"
}"
_rs
.
format
(
kv
.
first
,
kv
.
second
);
});
auto
inputSettingsString
=
",
\n
"
_rs
.
join
(
inputSettingStrings
);
return
rlib
::
string
(
templates
::
ACTIVITY_DICT_TEMPLATE_UNESCAPED
).
replace_once
(
"__TEMPLATE_ARG_DictLines"
,
inputSettingsString
);
}
auto
generateXaml
()
const
{
rlib
::
string
xamlCode
=
templates
::
ACTIVITY_XAML_TEMPLATE
;
string
argType
,
argValue
;
if
(
explicitArgType
.
empty
()
&&
explicitArgValue
.
empty
())
{
// no explicit argument specified.
if
(
inputSettings
.
empty
())
{
// Also no inputSettings.
xamlCode
=
templates
::
ACTIVITY_XAML_TEMPLATE_WITHOUT_INPUTSETTINGS
;
}
else
{
// Generate inputSettings.
argType
=
templates
::
ACTIVITY_DICT_TYPENAME
;
argValue
=
inputSettingsToCodelines
();
}
}
else
{
// Use explicit argument.
argType
=
explicitArgType
;
argValue
=
explicitArgValue
;
}
xamlCode
.
replace
(
"__TEMPLATE_ARG_TypeName"
,
argType
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_TypeValue"
,
argValue
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_ClassName"
,
this
->
className
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_DisplayName"
,
this
->
displayName
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_TaskId"
,
this
->
taskId
);
auto
entityXaml
=
this
->
entityName
==
""
?
""
:
rlib
::
string
(
templates
::
ENTITY_DEF_TEMPLATE
).
replace
(
"__TEMPLATE_ARG_EntityName"
,
this
->
entityName
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_EntityDefPlaceholder"
,
entityXaml
);
return
xamlCode
;
}
};
};
class
Flow
{
class
Flow
{
public:
public:
Flow
(
const
Activity
&
activity
)
{
Flow
(
const
Activity
&
activity
)
{
xamlCode
=
templates
::
ACTIVITY_XAML_TEMPLATE
;
xamlCode
=
activity
.
generateXaml
();
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_ClassName"
,
activity
.
className
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_DisplayName"
,
activity
.
displayName
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_TaskId"
,
activity
.
taskId
);
auto
entityXaml
=
activity
.
entityName
==
""
?
""
:
rlib
::
string
(
templates
::
ENTITY_DEF_TEMPLATE
).
replace
(
"__TEMPLATE_ARG_EntityName"
,
activity
.
entityName
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_EntityDefPlaceholder"
,
entityXaml
);
std
::
list
<
string
>
inputSettingStrings
;
std
::
transform
(
activity
.
inputSettings
.
begin
(),
activity
.
inputSettings
.
end
(),
std
::
back_inserter
(
inputSettingStrings
),
[](
auto
&&
kv
)
{
return
"{
\"
{}
\"
,
\"
{}
\"
}"
_rs
.
format
(
kv
.
first
,
kv
.
second
);
});
auto
inputSettingsString
=
",
\n
"
_rs
.
join
(
inputSettingStrings
);
xamlCode
.
replace_once
(
"__TEMPLATE_ARG_DictLines"
,
inputSettingsString
);
}
}
Flow
(
rlib
::
string
xamlCode
)
:
xamlCode
(
xamlCode
)
{}
Flow
(
rlib
::
string
xamlCode
)
:
xamlCode
(
xamlCode
)
{}
Flow
(
const
Flow
&
another
)
:
queued
(
another
.
queued
),
xamlCode
(
another
.
xamlCode
),
prevOperationIsSequential
(
another
.
prevOperationIsSequential
)
{}
Flow
(
const
Flow
&
another
)
:
queued
(
another
.
queued
),
xamlCode
(
another
.
xamlCode
),
prevOperationIsSequential
(
another
.
prevOperationIsSequential
)
{}
...
...
This diff is collapsed.
Click to expand it.
u
uid
.hpp
→
u
tility
.hpp
+
11
−
1
View file @
34a875db
...
@@ -3,8 +3,12 @@
...
@@ -3,8 +3,12 @@
#include
<random>
#include
<random>
#include
<string>
#include
<string>
#include
<rlib/string.hpp>
inline
static
std
::
string
GenUUID
()
{
namespace
Utility
{
inline
static
auto
GenUUID
()
{
static
std
::
random_device
dev
;
static
std
::
random_device
dev
;
static
std
::
mt19937
rng
(
dev
());
static
std
::
mt19937
rng
(
dev
());
...
@@ -22,4 +26,10 @@ inline static std::string GenUUID() {
...
@@ -22,4 +26,10 @@ inline static std::string GenUUID() {
return
res
;
return
res
;
}
}
inline
static
auto
HtmlEscapeString
(
rlib
::
string
s
)
{
return
s
.
replace
(
"&"
,
"&"
).
replace
(
"<"
,
"<"
).
replace
(
">"
,
">"
);
}
}
#endif
#endif
\ No newline at end of file
This diff is collapsed.
Click to expand it.
xaml-template.hpp
+
15
−
6
View file @
34a875db
...
@@ -12,17 +12,26 @@ namespace templates {
...
@@ -12,17 +12,26 @@ namespace templates {
constexpr
auto
ACTIVITY_XAML_TEMPLATE
=
constexpr
auto
ACTIVITY_XAML_TEMPLATE
=
R"XAMLTL( <mwcwa:ControlledActivity ClassName="__TEMPLATE_ARG_ClassName" DisplayName="__TEMPLATE_ARG_DisplayName" TaskId="__TEMPLATE_ARG_TaskId" __TEMPLATE_ARG_EntityDefPlaceholder>
R"XAMLTL( <mwcwa:ControlledActivity ClassName="__TEMPLATE_ARG_ClassName" DisplayName="__TEMPLATE_ARG_DisplayName" TaskId="__TEMPLATE_ARG_TaskId" __TEMPLATE_ARG_EntityDefPlaceholder>
<mwcwa:ControlledActivity.InputSettings>
<mwcwa:ControlledActivity.InputSettings>
<InArgument x:TypeArguments="scg:Dictionary(x:String, x:String)">
<InArgument x:TypeArguments="__TEMPLATE_ARG_TypeName">
<mca:CSharpValue x:TypeArguments="scg:Dictionary(x:String, x:String)" xml:space="preserve">
<mca:CSharpValue x:TypeArguments="__TEMPLATE_ARG_TypeName" xml:space="preserve">
new Dictionary<string, string>()
__TEMPLATE_ARG_TypeValue
{
__TEMPLATE_ARG_DictLines
}
</mca:CSharpValue>
</mca:CSharpValue>
</InArgument>
</InArgument>
</mwcwa:ControlledActivity.InputSettings>
</mwcwa:ControlledActivity.InputSettings>
</mwcwa:ControlledActivity>
</mwcwa:ControlledActivity>
)XAMLTL"
;
)XAMLTL"
;
constexpr
auto
ACTIVITY_XAML_TEMPLATE_WITHOUT_INPUTSETTINGS
=
R"XAMLTL( <mwcwa:ControlledActivity ClassName="__TEMPLATE_ARG_ClassName" DisplayName="__TEMPLATE_ARG_DisplayName" TaskId="__TEMPLATE_ARG_TaskId" InputSettings="{x:Null}" __TEMPLATE_ARG_EntityDefPlaceholder>
</mwcwa:ControlledActivity>
)XAMLTL"
;
constexpr
auto
ACTIVITY_DICT_TYPENAME
=
"scg:Dictionary(x:String, x:String)"
;
constexpr
auto
ACTIVITY_DICT_TEMPLATE_UNESCAPED
=
R"XAMLTL( new Dictionary<string, string>()
{
__TEMPLATE_ARG_DictLines
}
)XAMLTL"
;
constexpr
auto
ENTITY_DEF_TEMPLATE
=
R"(coordination:DependencyBinder.EntityName="__TEMPLATE_ARG_EntityName")"
;
constexpr
auto
ENTITY_DEF_TEMPLATE
=
R"(coordination:DependencyBinder.EntityName="__TEMPLATE_ARG_EntityName")"
;
...
...
This diff is collapsed.
Click to expand it.
xaml.gen.example.cc
+
5
−
1
View file @
34a875db
...
@@ -31,10 +31,14 @@ auto complexExample() {
...
@@ -31,10 +31,14 @@ auto complexExample() {
DEFINE_ACTIVITY
(
IntegrationTesting
,
""
)
DEFINE_ACTIVITY
(
IntegrationTesting
,
""
)
DEFINE_ACTIVITY
(
TSConfigAndInterop
,
"PreRteg.InitiateBareMetalComplete"
)
DEFINE_ACTIVITY
(
TSConfigAndInterop
,
"PreRteg.InitiateBareMetalComplete"
)
// All Names of activity should not contain quotation mark (")
Activity
OneMoreMagicActivity
(
"MyName Contains Symbols: {(<&>)}"
,
"FleetAGC.Workflow.Magic"
);
OneMoreMagicActivity
.
explicitSetRawArgument
(
"x:Boolean"
,
"(0b_1100_1000 | 0b_1000_0001 == 201)"
);
auto
block1
=
SCS
>>
(
SearchAnalytics
|
(
SearchFarms
>>
(
ClassisSearchUX
|
ModernSearch
)));
auto
block1
=
SCS
>>
(
SearchAnalytics
|
(
SearchFarms
>>
(
ClassisSearchUX
|
ModernSearch
)));
auto
block3
=
Loki
>>
Yggdrasil
>>
OfficeGraph
;
auto
block3
=
Loki
>>
Yggdrasil
>>
OfficeGraph
;
auto
block4
=
IC3Tooling
>>
(
MonitoringSetup
|
(
MicroServices
>>
DevelopmentValidation
>>
IntegrationTesting
));
auto
block4
=
IC3Tooling
>>
(
MonitoringSetup
|
(
MicroServices
>>
DevelopmentValidation
>>
IntegrationTesting
));
auto
completeFlow
=
block1
|
TSConfigAndInterop
|
block3
|
block4
;
auto
completeFlow
=
(
block1
|
TSConfigAndInterop
|
block3
|
block4
)
>>
OneMoreMagicActivity
;
auto
myMetadata
=
Metadata
(
"FleetAGC.Workflows.BuildTeams"
).
setXtraAssemblies
({
"FleetAGC.Workflows"
});
auto
myMetadata
=
Metadata
(
"FleetAGC.Workflows.BuildTeams"
).
setXtraAssemblies
({
"FleetAGC.Workflows"
});
println
(
to_file
(
"BuildTeams.xaml"
),
completeFlow
.
generateXaml
(
myMetadata
));
println
(
to_file
(
"BuildTeams.xaml"
),
completeFlow
.
generateXaml
(
myMetadata
));
...
...
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