Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97869879
URLParserMaterial.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jan 7, 00:03
Size
1 KB
Mime Type
text/x-java
Expires
Thu, Jan 9, 00:03 (2 d)
Engine
blob
Format
Raw Data
Handle
23423940
Attached To
R3229 Genome Privacy - SHCS App
URLParserMaterial.java
View Options
package
io.serializer.url
;
import
io.serializer.ParserNamespace
;
import
java.util.LinkedList
;
import
utils.StringUtils
;
import
framework.MarkerEncrypted
;
import
framework.request.RequestMaterial
;
public
class
URLParserMaterial
extends
URLParser
{
public
static
String
requestToString
(
RequestMaterial
request
)
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
ParserNamespace
.
CNAME_PATIENT
).
append
(
QUERY_ASSIGN
);
sb
.
append
(
Integer
.
toString
(
request
.
getPatientId
()));
sb
.
append
(
QUERY_AND
);
sb
.
append
(
ParserNamespace
.
CNAME_MARKER_ID_LIST
).
append
(
QUERY_ASSIGN
);
sb
.
append
(
StringUtils
.
join
(
SEP_EXT
,
request
.
getRequiredMarkers
()));
sb
.
append
(
QUERY_AND
);
sb
.
append
(
ParserNamespace
.
CNAME_CF_ID_LIST
).
append
(
QUERY_ASSIGN
);
sb
.
append
(
StringUtils
.
join
(
SEP_EXT
,
request
.
getRequiredCFs
()));
return
sb
.
toString
();
}
public
static
RequestMaterial
stringToRequest
(
String
requestString
)
{
String
[]
parts
=
requestString
.
split
(
QUERY_AND
);
int
patientId
=
extractPatientId
(
parts
[
0
]);
LinkedList
<
MarkerEncrypted
>
markers
=
extractMarkerId
(
parts
[
1
]);
LinkedList
<
MarkerEncrypted
>
cfs
=
extractCFId
(
parts
[
2
]);
RequestMaterial
request
=
new
RequestMaterial
(
markers
,
cfs
,
patientId
);
return
request
;
}
private
static
LinkedList
<
MarkerEncrypted
>
extractMarkerId
(
String
val
)
{
String
markersConcat
=
extractVal
(
val
,
ParserNamespace
.
CNAME_MARKER_ID_LIST
);
LinkedList
<
MarkerEncrypted
>
markers
=
new
LinkedList
<>();
String
[]
markersString
=
markersConcat
.
split
(
SEP_EXT
);
for
(
String
marker
:
markersString
)
{
markers
.
add
(
new
MarkerEncrypted
(
marker
));
}
return
markers
;
}
private
static
LinkedList
<
MarkerEncrypted
>
extractCFId
(
String
val
)
{
String
cfsConcat
=
extractVal
(
val
,
ParserNamespace
.
CNAME_CF_ID_LIST
);
LinkedList
<
MarkerEncrypted
>
cfs
=
new
LinkedList
<>();
String
[]
cfsString
=
cfsConcat
.
split
(
SEP_EXT
);
for
(
String
cf
:
cfsString
)
{
cfs
.
add
(
new
MarkerEncrypted
(
cf
));
}
return
cfs
;
}
}
Event Timeline
Log In to Comment