Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
xrm
basic
Commits
4762a024
Commit
4762a024
authored
5 years ago
by
Johannes Hörmann
Browse files
Options
Downloads
Patches
Plain Diff
Org report -> html to text
parent
daf60437
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Organisation_lib/process.js
+187
-180
187 additions, 180 deletions
process/Organisation_lib/process.js
with
187 additions
and
180 deletions
process/Organisation_lib/process.js
+
187
−
180
View file @
4762a024
import
(
"
Util_lib
"
);
import
(
"
system.datetime
"
);
import
(
"
system.translate
"
);
import
(
"
system.db
"
);
import
(
"
Binary_lib
"
);
import
(
"
Report_lib
"
);
import
(
"
Sql_lib
"
);
import
(
"
Keyword_lib
"
);
import
(
"
Attribute_lib
"
);
import
(
"
PostalAddress_lib
"
);
import
(
"
Communication_lib
"
);
import
(
"
KeywordRegistry_basic
"
);
/**
* a static Utility class for the Org context.
*
* Do not create an instance of this!
* @class
*/
function
OrgUtils
()
{}
/**
* returns the image for a organisation
*
* @param {String} pOrgId the id of the organisation.
* @param {String} pDefaultText the text, to use for default image generation.
* @return {String} base64 coded String of the image. If none existed, the given String is used to create an image.
*/
OrgUtils
.
getImage
=
function
(
pOrgId
,
pDefaultText
)
{
return
ImageUtils
.
get
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
,
pDefaultText
);
}
/**
* sets the image of a organisation
*
* @param {String} pOrgId the id of the organisation.
* @param {String} pImageDateBase64 base64 coded String of the image.
* @return {Boolean} if image could be set
*/
OrgUtils
.
setImage
=
function
(
pOrgId
,
pImageDateBase64
)
{
return
ImageUtils
.
set
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
,
pImageDateBase64
,
"
OrgImage
"
,
"
Image of the organisation
"
);
}
/**
* deletes the image of a organisation
*
* @param {String} pOrgId the id of the organisation.
* @return {Boolean} if image could be removed
*/
OrgUtils
.
removeImage
=
function
(
pOrgId
)
{
return
ImageUtils
.
remove
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
);
}
/**
* opens the org-report
*
* @param {String} pOrgId the id of the organization
*/
OrgUtils
.
openOrgReport
=
function
(
pOrgId
)
{
var
relationId
=
pOrgId
;
//org info
var
info
=
db
.
cell
(
SqlCondition
.
begin
()
.
andPrepare
(
"
ORGANISATION.ORGANISATIONID
"
,
pOrgId
)
.
buildSql
(
"
select ORGANISATION.INFO from ORGANISATION
"
));
//communication data of the organization
var
commSql
=
"
select MEDIUM_ID, ADDR from COMMUNICATION
"
;
commSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
COMMUNICATION.CONTACT_ID
"
,
relationId
)
.
and
(
"
STANDARD = 1
"
)
.
buildSql
(
commSql
);
var
commData
=
db
.
table
(
commSql
);
//resolve keyword
commData
.
forEach
(
function
(
row
)
{
row
[
0
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
communicationMedium
(),
row
[
0
]);
});
commData
=
ReportData
.
begin
([
"
KINDOFCOMM
"
,
"
COMMVALUE
"
]).
add
(
commData
);
//select people from the organization
var
persSql
=
"
select SALUTATION, TITLE, FIRSTNAME, LASTNAME
"
+
"
,CONTACTROLE as PERSFUNCITON, DEPARTMENT as PERSDEPARTMENT
"
+
"
,(
"
+
CommUtil
.
getStandardSubSqlMail
()
+
"
)
"
+
"
,(
"
+
CommUtil
.
getStandardSubSqlPhone
()
+
"
)
"
+
"
,ORGANISATION_ID, CONTACTID
"
+
"
from PERSON join CONTACT on PERSONID = PERSON_ID
"
;
persSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
.
and
(
"
CONTACT.STATUS = '
"
+
$KeywordRegistry
.
contactStatus
$active
()
+
"
'
"
)
//TODO: replace this with something that isn't a hard coded id
.
buildSql
(
persSql
,
""
,
"
order by PERSON.LASTNAME asc
"
);
var
persData
=
db
.
table
(
persSql
);
for
(
let
i
=
0
;
i
<
persData
.
length
;
i
++
)
{
_joinArrayVals
(
persData
[
i
],
0
,
4
);
//join the full name together
_joinArrayVals
(
persData
[
i
],
3
,
2
,
"
\n
"
);
//join communication together
}
persData
=
ReportData
.
begin
([
"
PERSNAMECOMPLETE
"
,
"
PERSFUNCTION
"
,
"
PERSDEPARTMENT
"
,
"
PERSCOMM
"
,
"
ORGANISATION_ID
"
,
"
CONTACT_ID
"
]).
add
(
persData
);
var
histSql
=
"
select ENTRYDATE, CATEGORY, FIRSTNAME, LASTNAME, INFO from ACTIVITY
"
+
"
join ACTIVITYLINK on ACTIVITYLINK.ACTIVITY_ID = ACTIVITYID
"
+
"
join CONTACT on ACTIVITYLINK.OBJECT_ROWID = CONTACTID
"
+
"
left join PERSON on CONTACT.PERSON_ID = PERSONID
"
;
histSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
//= all activities linked to the organization or an employee
.
buildSql
(
histSql
,
""
,
"
order by ENTRYDATE desc
"
);
var
histData
=
db
.
table
(
histSql
);
var
dateFormat
=
translate
.
text
(
"
dd.MM.yyyy
"
);
histData
.
forEach
(
function
(
row
)
{
row
[
0
]
=
datetime
.
toDate
(
row
[
0
],
dateFormat
);
row
[
1
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
activityCategory
(),
row
[
1
]);
_joinArrayVals
(
row
,
2
,
2
);
});
histData
=
ReportData
.
begin
([
"
ENTRYDATE
"
,
"
MEDIUM
"
,
"
LOGIN
"
,
"
INFO
"
]).
add
(
histData
);
var
attr
=
AttributeRelationUtils
.
getAllAttributes
(
pOrgId
)
.
map
(
function
(
row
)
{
return
row
[
1
]
?
row
.
join
(
"
:
"
)
:
row
[
0
]})
.
join
(
"
\n
"
);
//tasks
var
taskSql
=
"
select TASK.SUBJECT, TASK.DESCRIPTION, TASK.STATUS, FIRSTNAME, LASTNAME from TASK
"
+
"
join CONTACT on EDITOR_CONTACT_ID = CONTACTID
"
+
"
left join PERSON on CONTACT.PERSON_ID = PERSONID
"
;
taskSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
.
buildSql
(
taskSql
);
var
taskData
=
db
.
table
(
taskSql
);
taskData
.
forEach
(
function
(
row
)
{
row
[
2
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
taskStatus
(),
row
[
2
]);
_joinArrayVals
(
row
,
3
,
2
);
//join FIRSTNAME and LASTNAME together
});
taskData
=
ReportData
.
begin
([
"
SUBJECT
"
,
"
INFOTEXT
"
,
"
STATUS
"
,
"
RESPONSIBLE
"
]).
add
(
taskData
);
var
params
=
{
"
ORGAddr
"
:
AddressUtils
.
getAddress
(
relationId
).
toString
(),
//TODO: use new address logic when available
"
ORGAttr
"
:
attr
,
"
INFO
"
:
info
};
var
orgReport
=
new
Report
(
"
Organisation_report
"
,
params
);
//add subreport data
orgReport
.
addSubReportData
(
"
subdataComm
"
,
commData
);
orgReport
.
addSubReportData
(
"
subdataPers
"
,
persData
);
orgReport
.
addSubReportData
(
"
subdataHist
"
,
histData
);
orgReport
.
addSubReportData
(
"
subdataTask
"
,
taskData
);
//add logo
//TODO: use an function to get the image when available
var
imgData
=
[
"
meineFirma | Konrad-Zuse-Straße 4 | DE 84144 Geisenhausen
"
,
"
base64:iVBORw0KGgoAAAANSUhEUgAAAM4AAABRCAYAAACaL5lSAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek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2o16IqxwAi5ri7mcsd5vVsNguyhp/co44fPdzZTur7aQxZ0wwW5DqioczO6Mq4dZfO/Aex5uhcO3VqOr5l6EpVih0RcrbL/R5ayHqSj2RwURhdqeFZWzx5s1i62ScDAlOh706s+gcC4npHHVSoshoRDB9Fjjw7qpdq8apkTH7M5LM75fnTNeUc74rSxn5kTjXFtyGLDHUAhE1HDHeCDhYGWYEr13nginBQPwIBcfWc5UsdcKLmyLYoVB3h192mR/GvRRnwE4y5n+3qbdcnErBSvaoxbOmNjJLO9cRKGsgWehylX7rmZdlU9LOdM2RtS7ClqiFg44IfbXtO6thQvvuBkgWd7auePuRqcN8Zi5faGsWaSlnIlAw9yOS1vQIIEjmDb7frkogwMOcNWGTPnNMGl7O8zknYsX/UA+76p2NpcGB/93WBslzugFn+QTzapMWsqZMPLW/sI9ae7l3ToOChxxq2UO0HfEXjXpegAMZX118aKFNwM2SvjAqzXqUvRohPi/tdkv4khLORPU64yoONxjHNyVsD7MbUU5rzd67Nr/eqU8+8UOp2Sf/VbsiN/CU0deYKsioVgQIs9RsUMpqNshLSshkRPmZR23tFF+L7bPJG/69hsqmKNaVkISIRxHPHCBvhHbk6CAwaSOw47x0JIkCscBDfRzU76frdnTuSNcPqRBDEISLRyjDfWSKUdzMCV6o+edQagcF2hPmOzf4UAyJByn8R405bsMMCU6ZneO+8bQf5nyfXSnzdznawhJhXAcxtQQL8fszpioNurnefCMEB53wJ3bvDpOMiEch7NqGHNgotpOU54+MOw7DPCOgHMqSjyEdpmHjmRROA6X1YZ07IPpAzETGqJwmJ8GU21g1gAnpI1QMt6wiZcF4r1niJLhbTQfcfxCkkQuyFwghJDZLOAuIITCIYTCIYTCIYTCIYTCIYRQOIRQOIRQOIRQOIRQOISQWvi/AAMA9UczDEaG0p8AAAAASUVORK5CYII=
"
];
params
[
"
myAddr
"
]
=
imgData
[
0
];
orgReport
.
addImage
(
"
myLogo
"
,
imgData
[
1
]);
orgReport
.
openReport
();
/*
* merges multiple columns in an two-dimensional array into one
*/
function
_joinArrayVals
(
pArr
,
pIndex
,
pHowMany
,
pJoinSeparator
)
{
if
(
pJoinSeparator
==
undefined
)
pJoinSeparator
=
"
"
;
pArr
.
splice
(
pIndex
,
pHowMany
,
ArrayUtils
.
joinNonEmptyFields
(
pArr
.
slice
(
pIndex
,
pIndex
+
pHowMany
),
pJoinSeparator
)
);
}
import
(
"
Util_lib
"
);
import
(
"
system.datetime
"
);
import
(
"
system.translate
"
);
import
(
"
system.db
"
);
import
(
"
system.text
"
);
import
(
"
Binary_lib
"
);
import
(
"
Report_lib
"
);
import
(
"
Sql_lib
"
);
import
(
"
Keyword_lib
"
);
import
(
"
Attribute_lib
"
);
import
(
"
PostalAddress_lib
"
);
import
(
"
Communication_lib
"
);
import
(
"
KeywordRegistry_basic
"
);
/**
* a static Utility class for the Org context.
*
* Do not create an instance of this!
* @class
*/
function
OrgUtils
()
{}
/**
* returns the image for a organisation
*
* @param {String} pOrgId the id of the organisation.
* @param {String} pDefaultText the text, to use for default image generation.
* @return {String} base64 coded String of the image. If none existed, the given String is used to create an image.
*/
OrgUtils
.
getImage
=
function
(
pOrgId
,
pDefaultText
)
{
return
ImageUtils
.
get
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
,
pDefaultText
);
}
/**
* sets the image of a organisation
*
* @param {String} pOrgId the id of the organisation.
* @param {String} pImageDateBase64 base64 coded String of the image.
* @return {Boolean} if image could be set
*/
OrgUtils
.
setImage
=
function
(
pOrgId
,
pImageDateBase64
)
{
return
ImageUtils
.
set
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
,
pImageDateBase64
,
"
OrgImage
"
,
"
Image of the organisation
"
);
}
/**
* deletes the image of a organisation
*
* @param {String} pOrgId the id of the organisation.
* @return {Boolean} if image could be removed
*/
OrgUtils
.
removeImage
=
function
(
pOrgId
)
{
return
ImageUtils
.
remove
(
"
ORGANISATION
"
,
"
IMAGE
"
,
pOrgId
);
}
/**
* opens the org-report
*
* @param {String} pOrgId the id of the organization
*/
OrgUtils
.
openOrgReport
=
function
(
pOrgId
)
{
var
relationId
=
pOrgId
;
//org info
var
info
=
db
.
cell
(
SqlCondition
.
begin
()
.
andPrepare
(
"
ORGANISATION.ORGANISATIONID
"
,
pOrgId
)
.
buildSql
(
"
select ORGANISATION.INFO from ORGANISATION
"
));
//communication data of the organization
var
commSql
=
"
select MEDIUM_ID, ADDR from COMMUNICATION
"
;
commSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
COMMUNICATION.CONTACT_ID
"
,
relationId
)
.
and
(
"
STANDARD = 1
"
)
.
buildSql
(
commSql
);
var
commData
=
db
.
table
(
commSql
);
//resolve keyword
commData
.
forEach
(
function
(
row
)
{
row
[
0
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
communicationMedium
(),
row
[
0
]);
});
commData
=
ReportData
.
begin
([
"
KINDOFCOMM
"
,
"
COMMVALUE
"
]).
add
(
commData
);
//select people from the organization
var
persSql
=
"
select SALUTATION, TITLE, FIRSTNAME, LASTNAME
"
+
"
,CONTACTROLE as PERSFUNCITON, DEPARTMENT as PERSDEPARTMENT
"
+
"
,(
"
+
CommUtil
.
getStandardSubSqlMail
()
+
"
)
"
+
"
,(
"
+
CommUtil
.
getStandardSubSqlPhone
()
+
"
)
"
+
"
,ORGANISATION_ID, CONTACTID
"
+
"
from PERSON join CONTACT on PERSONID = PERSON_ID
"
;
persSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
.
and
(
"
CONTACT.STATUS = '
"
+
$KeywordRegistry
.
contactStatus
$active
()
+
"
'
"
)
//TODO: replace this with something that isn't a hard coded id
.
buildSql
(
persSql
,
""
,
"
order by PERSON.LASTNAME asc
"
);
var
persData
=
db
.
table
(
persSql
);
for
(
let
i
=
0
;
i
<
persData
.
length
;
i
++
)
{
_joinArrayVals
(
persData
[
i
],
0
,
4
);
//join the full name together
_joinArrayVals
(
persData
[
i
],
3
,
2
,
"
\n
"
);
//join communication together
}
persData
=
ReportData
.
begin
([
"
PERSNAMECOMPLETE
"
,
"
PERSFUNCTION
"
,
"
PERSDEPARTMENT
"
,
"
PERSCOMM
"
,
"
ORGANISATION_ID
"
,
"
CONTACT_ID
"
]).
add
(
persData
);
var
histSql
=
"
select ENTRYDATE, CATEGORY, FIRSTNAME, LASTNAME, INFO from ACTIVITY
"
+
"
join ACTIVITYLINK on ACTIVITYLINK.ACTIVITY_ID = ACTIVITYID
"
+
"
join CONTACT on ACTIVITYLINK.OBJECT_ROWID = CONTACTID
"
+
"
left join PERSON on CONTACT.PERSON_ID = PERSONID
"
;
histSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
//= all activities linked to the organization or an employee
.
buildSql
(
histSql
,
""
,
"
order by ENTRYDATE desc
"
);
var
histData
=
db
.
table
(
histSql
);
var
dateFormat
=
translate
.
text
(
"
dd.MM.yyyy
"
);
histData
.
forEach
(
function
(
row
)
{
row
[
0
]
=
datetime
.
toDate
(
row
[
0
],
dateFormat
);
// convert html to text
if
(
row
[
1
]
==
$KeywordRegistry
.
activityCategory
$mail
())
{
row
[
4
]
=
text
.
html2text
(
row
[
4
]);
}
row
[
1
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
activityCategory
(),
row
[
1
]);
_joinArrayVals
(
row
,
2
,
2
);
});
histData
=
ReportData
.
begin
([
"
ENTRYDATE
"
,
"
MEDIUM
"
,
"
LOGIN
"
,
"
INFO
"
]).
add
(
histData
);
var
attr
=
AttributeRelationUtils
.
getAllAttributes
(
pOrgId
)
.
map
(
function
(
row
)
{
return
row
[
1
]
?
row
.
join
(
"
:
"
)
:
row
[
0
]})
.
join
(
"
\n
"
);
//tasks
var
taskSql
=
"
select TASK.SUBJECT, TASK.DESCRIPTION, TASK.STATUS, FIRSTNAME, LASTNAME from TASK
"
+
"
join CONTACT on EDITOR_CONTACT_ID = CONTACTID
"
+
"
left join PERSON on CONTACT.PERSON_ID = PERSONID
"
;
taskSql
=
SqlCondition
.
begin
()
.
andPrepare
(
"
CONTACT.ORGANISATION_ID
"
,
pOrgId
)
.
buildSql
(
taskSql
);
var
taskData
=
db
.
table
(
taskSql
);
taskData
.
forEach
(
function
(
row
)
{
row
[
2
]
=
KeywordUtils
.
getViewValue
(
$KeywordRegistry
.
taskStatus
(),
row
[
2
]);
_joinArrayVals
(
row
,
3
,
2
);
//join FIRSTNAME and LASTNAME together
});
taskData
=
ReportData
.
begin
([
"
SUBJECT
"
,
"
INFOTEXT
"
,
"
STATUS
"
,
"
RESPONSIBLE
"
]).
add
(
taskData
);
var
params
=
{
"
ORGAddr
"
:
AddressUtils
.
getAddress
(
relationId
).
toString
(),
//TODO: use new address logic when available
"
ORGAttr
"
:
attr
,
"
INFO
"
:
info
};
var
orgReport
=
new
Report
(
"
Organisation_report
"
,
params
);
//add subreport data
orgReport
.
addSubReportData
(
"
subdataComm
"
,
commData
);
orgReport
.
addSubReportData
(
"
subdataPers
"
,
persData
);
orgReport
.
addSubReportData
(
"
subdataHist
"
,
histData
);
orgReport
.
addSubReportData
(
"
subdataTask
"
,
taskData
);
//add logo
//TODO: use an function to get the image when available
var
imgData
=
[
"
meineFirma | Konrad-Zuse-Straße 4 | DE 84144 Geisenhausen
"
,
"
base64:iVBORw0KGgoAAAANSUhEUgAAAM4AAABRCAYAAACaL5lSAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1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xn5kTjXFtyGLDHUAhE1HDHeCDhYGWYEr13nginBQPwIBcfWc5UsdcKLmyLYoVB3h192mR/GvRRnwE4y5n+3qbdcnErBSvaoxbOmNjJLO9cRKGsgWehylX7rmZdlU9LOdM2RtS7ClqiFg44IfbXtO6thQvvuBkgWd7auePuRqcN8Zi5faGsWaSlnIlAw9yOS1vQIIEjmDb7frkogwMOcNWGTPnNMGl7O8zknYsX/UA+76p2NpcGB/93WBslzugFn+QTzapMWsqZMPLW/sI9ae7l3ToOChxxq2UO0HfEXjXpegAMZX118aKFNwM2SvjAqzXqUvRohPi/tdkv4khLORPU64yoONxjHNyVsD7MbUU5rzd67Nr/eqU8+8UOp2Sf/VbsiN/CU0deYKsioVgQIs9RsUMpqNshLSshkRPmZR23tFF+L7bPJG/69hsqmKNaVkISIRxHPHCBvhHbk6CAwaSOw47x0JIkCscBDfRzU76frdnTuSNcPqRBDEISLRyjDfWSKUdzMCV6o+edQagcF2hPmOzf4UAyJByn8R405bsMMCU6ZneO+8bQf5nyfXSnzdznawhJhXAcxtQQL8fszpioNurnefCMEB53wJ3bvDpOMiEch7NqGHNgotpOU54+MOw7DPCOgHMqSjyEdpmHjmRROA6X1YZ07IPpAzETGqJwmJ8GU21g1gAnpI1QMt6wiZcF4r1niJLhbTQfcfxCkkQuyFwghJDZLOAuIITCIYTCIYTCIYTCIYTCIYRQOIRQOIRQOIRQOIRQOISQWvi/AAMA9UczDEaG0p8AAAAASUVORK5CYII=
"
];
params
[
"
myAddr
"
]
=
imgData
[
0
];
orgReport
.
addImage
(
"
myLogo
"
,
imgData
[
1
]);
orgReport
.
openReport
();
/*
* merges multiple columns in an two-dimensional array into one
*/
function
_joinArrayVals
(
pArr
,
pIndex
,
pHowMany
,
pJoinSeparator
)
{
if
(
pJoinSeparator
==
undefined
)
pJoinSeparator
=
"
"
;
pArr
.
splice
(
pIndex
,
pHowMany
,
ArrayUtils
.
joinNonEmptyFields
(
pArr
.
slice
(
pIndex
,
pIndex
+
pHowMany
),
pJoinSeparator
)
);
}
}
\ No newline at end of file
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