Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
6c8680d1
Commit
6c8680d1
authored
12 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
Create count query when creating code generator.
SVN: 27582
parent
14280b3d
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
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityCodeGenerator.java
+26
-31
26 additions, 31 deletions
...enbis/generic/server/business/bo/EntityCodeGenerator.java
with
26 additions
and
31 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/EntityCodeGenerator.java
+
26
−
31
View file @
6c8680d1
...
@@ -38,14 +38,33 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.TableNames;
...
@@ -38,14 +38,33 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.TableNames;
*/
*/
public
class
EntityCodeGenerator
public
class
EntityCodeGenerator
{
{
private
final
IDAOFactory
daoFactory
;
private
IDAOFactory
daoFacto
ry
;
private
final
CountQuery
countQue
ry
;
private
Query
query
;
private
interface
CountQuery
extends
BaseQuery
{
public
final
static
String
PREFIX
=
"SELECT count(*) FROM "
;
public
final
static
String
SUFFIX
=
" WHERE code = ?{1}"
;
@Select
(
sql
=
PREFIX
+
TableNames
.
EXPERIMENTS_ALL_TABLE
+
SUFFIX
)
public
int
getExperimentCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
SAMPLES_ALL_TABLE
+
SUFFIX
)
public
int
getSampleCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
DATA_ALL_TABLE
+
SUFFIX
)
public
int
getDataSetCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
MATERIALS_TABLE
+
SUFFIX
)
public
int
getMaterialsCount
(
String
code
);
}
public
EntityCodeGenerator
(
IDAOFactory
daoFactory
)
public
EntityCodeGenerator
(
IDAOFactory
daoFactory
)
{
{
this
.
daoFactory
=
daoFactory
;
this
.
daoFactory
=
daoFactory
;
this
.
countQuery
=
QueryTool
.
getManagedQuery
(
CountQuery
.
class
);
}
}
public
String
generateCode
(
String
codePrefix
,
EntityKind
entityKind
)
public
String
generateCode
(
String
codePrefix
,
EntityKind
entityKind
)
...
@@ -64,10 +83,7 @@ public class EntityCodeGenerator
...
@@ -64,10 +83,7 @@ public class EntityCodeGenerator
*/
*/
public
List
<
String
>
generateCodes
(
String
codePrefix
,
EntityKind
entityKind
,
int
numberOfCodes
)
public
List
<
String
>
generateCodes
(
String
codePrefix
,
EntityKind
entityKind
,
int
numberOfCodes
)
{
{
String
[]
codes
=
new
String
[
numberOfCodes
];
final
String
[]
codes
=
new
String
[
numberOfCodes
];
query
=
QueryTool
.
getManagedQuery
(
Query
.
class
);
for
(
int
i
=
0
;
i
<
numberOfCodes
;
i
++)
for
(
int
i
=
0
;
i
<
numberOfCodes
;
i
++)
{
{
long
sequenceValue
;
long
sequenceValue
;
...
@@ -92,16 +108,16 @@ public class EntityCodeGenerator
...
@@ -92,16 +108,16 @@ public class EntityCodeGenerator
if
(
EntityKind
.
EXPERIMENT
.
equals
(
entityKind
))
if
(
EntityKind
.
EXPERIMENT
.
equals
(
entityKind
))
{
{
count
=
q
uery
.
getExperimentCount
(
code
);
count
=
countQ
uery
.
getExperimentCount
(
code
);
}
else
if
(
EntityKind
.
SAMPLE
.
equals
(
entityKind
))
}
else
if
(
EntityKind
.
SAMPLE
.
equals
(
entityKind
))
{
{
count
=
q
uery
.
getSampleCount
(
code
);
count
=
countQ
uery
.
getSampleCount
(
code
);
}
else
if
(
EntityKind
.
DATA_SET
.
equals
(
entityKind
))
}
else
if
(
EntityKind
.
DATA_SET
.
equals
(
entityKind
))
{
{
count
=
q
uery
.
getDataSetCount
(
code
);
count
=
countQ
uery
.
getDataSetCount
(
code
);
}
else
if
(
EntityKind
.
MATERIAL
.
equals
(
entityKind
))
}
else
if
(
EntityKind
.
MATERIAL
.
equals
(
entityKind
))
{
{
count
=
q
uery
.
getMaterialsCount
(
code
);
count
=
countQ
uery
.
getMaterialsCount
(
code
);
}
else
}
else
{
{
throw
new
IllegalArgumentException
(
"Unsupported entity kind: "
+
entityKind
);
throw
new
IllegalArgumentException
(
"Unsupported entity kind: "
+
entityKind
);
...
@@ -110,25 +126,4 @@ public class EntityCodeGenerator
...
@@ -110,25 +126,4 @@ public class EntityCodeGenerator
return
count
>
0
;
return
count
>
0
;
}
}
private
interface
Query
extends
BaseQuery
{
public
final
static
String
PREFIX
=
"SELECT count(*) FROM "
;
public
final
static
String
SUFFIX
=
" WHERE code = ?{1}"
;
@Select
(
sql
=
PREFIX
+
TableNames
.
EXPERIMENTS_ALL_TABLE
+
SUFFIX
)
public
int
getExperimentCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
SAMPLES_ALL_TABLE
+
SUFFIX
)
public
int
getSampleCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
DATA_ALL_TABLE
+
SUFFIX
)
public
int
getDataSetCount
(
String
code
);
@Select
(
sql
=
PREFIX
+
TableNames
.
MATERIALS_TABLE
+
SUFFIX
)
public
int
getMaterialsCount
(
String
code
);
}
}
}
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