Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container 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
af3
kernel
Commits
a438cf0b
Commit
a438cf0b
authored
8 years ago
by
Vincent Aravantinos
Browse files
Options
Downloads
Patches
Plain Diff
extensions to prevent further useless constraint verifications
refs 2726
parent
1c32ba07
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
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintService.java
+47
-21
47 additions, 21 deletions
...rg/fortiss/tooling/kernel/internal/ConstraintService.java
with
47 additions
and
21 deletions
org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/ConstraintService.java
+
47
−
21
View file @
a438cf0b
...
...
@@ -46,7 +46,7 @@ import org.fortiss.tooling.kernel.service.IPersistencyService;
* @author aravantinos
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash:
1FC7269BEBCFB91D0029CCD01E2F5741
* @ConQAT.Rating YELLOW Hash:
6FA0E127A084C9499349FB4014005422
*/
public
final
class
ConstraintService
implements
IIntrospectiveKernelService
,
IConstraintService
{
...
...
@@ -148,10 +148,18 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
// And we also update the checksums after in case the verification had some side
// effects...
updateChecksums
(
ci
);
currentlyUpdating
.
remove
(
ci
);
});
}
}
/** Returns the short name of the constraint of the given instance. */
private
String
cstrShortName
(
ConstraintInstance
ci
)
{
int
dolIndex
=
ci
.
getConstraintName
().
lastIndexOf
(
'$'
);
int
dotIndex
=
ci
.
getConstraintName
().
lastIndexOf
(
'.'
);
return
ci
.
getConstraintName
().
substring
(
Math
.
max
(
dotIndex
,
dolIndex
)
+
1
);
}
/** {@inheritDoc} */
@Override
public
List
<
IFix
>
fixes
(
ConstraintInstance
ci
)
{
...
...
@@ -191,14 +199,14 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
* This string should however only be set to a non-empty string on a local machine, never
* commited!
*/
private
static
final
String
DEBUG_F
ILE
=
"
"
;
private
static
final
String
DEBUG_F
OLDER
=
"/home/vincent/temp/cstr
"
;
/** Number used to annotate the traces when debugging is active. */
private
int
debug_trace_number
=
0
;
/**
*
@r
eturn the checksum of <code>constrained</code>. Note that <code>ci</code> is necessary
*
because it has a potential impact on what is relevant for the checksum or not.
*
R
eturn
s
the checksum of <code>constrained</code>. Note that <code>ci</code> is necessary
* because it has a potential impact on what is relevant for the checksum or not.
*/
protected
BigInteger
computeCheckSum
(
IConstrained
constrained
,
ConstraintInstance
ci
)
{
if
(
constrained
==
null
)
{
...
...
@@ -210,8 +218,8 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
try
{
final
ResourceSet
rset
=
new
ResourceSetImpl
();
oos
=
new
ObjectOutputStream
(
baos
);
Resource
res
=
rset
.
createResource
(
URI
.
createURI
(
"temp"
));
res
.
getContents
().
add
(
hashRelevant
);
Resource
res
ource
=
rset
.
createResource
(
URI
.
createURI
(
"temp"
));
res
ource
.
getContents
().
add
(
hashRelevant
);
Map
<
String
,
String
>
options
=
new
HashMap
<>();
// The option below is to allow computing the hashsum of an incomplete ecore sub-model,
...
...
@@ -219,27 +227,27 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
// referred to.
options
.
put
(
OPTION_PROCESS_DANGLING_HREF
,
OPTION_PROCESS_DANGLING_HREF_DISCARD
);
res
.
save
(
oos
,
options
);
if
(!
DEBUG_FILE
.
isEmpty
())
{
String
filePrefix
=
DEBUG_FILE
+
"/trace"
+
debug_trace_number
++;
String
nameConstraint
=
ci
instanceof
INamedElement
?
((
INamedElement
)
ci
).
getName
()
:
ci
.
toString
();
String
nameConstrained
=
resource
.
save
(
oos
,
options
);
oos
.
close
();
MessageDigest
m
=
MessageDigest
.
getInstance
(
"SHA1"
);
m
.
update
(
baos
.
toByteArray
());
BigInteger
res
=
new
BigInteger
(
1
,
m
.
digest
());
if
(
DEBUG_FOLDER
!=
null
)
{
String
filePrefix
=
DEBUG_FOLDER
+
"/trace"
+
debug_trace_number
++
+
null
;
String
nameCstr
=
cstrShortName
(
ci
);
String
nameCstrd
=
constrained
instanceof
INamedElement
?
((
INamedElement
)
constrained
)
.
getName
()
:
constrained
.
toString
();
String
fileName
=
filePrefix
+
"_"
+
nameConstraint
+
"_"
+
nameConstrained
+
".xml"
;
String
fileName
=
filePrefix
+
"_"
+
nameCstr
+
"_"
+
nameCstrd
+
".xml"
;
FileOutputStream
file
=
new
FileOutputStream
(
fileName
);
ObjectOutputStream
oos2
=
new
ObjectOutputStream
(
file
);
res
.
save
(
oos2
,
options
);
resource
.
save
(
oos2
,
options
);
oos2
.
writeUTF
(
"\nCHECKSUM: "
+
res
.
toString
());
oos2
.
close
();
}
oos
.
close
();
MessageDigest
m
=
MessageDigest
.
getInstance
(
"SHA1"
);
m
.
update
(
baos
.
toByteArray
());
res
.
getContents
().
remove
(
hashRelevant
);
res
.
delete
(
options
);
return
new
BigInteger
(
1
,
m
.
digest
());
resource
.
getContents
().
remove
(
hashRelevant
);
resource
.
delete
(
options
);
return
res
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
...
...
@@ -326,4 +334,22 @@ public final class ConstraintService implements IIntrospectiveKernelService, ICo
public
Class
<?
extends
IConstraint
>
getConstraintByName
(
String
name
)
{
return
handlerMap
.
get
(
name
);
}
/**
* List of constraint instances being currently updated, to prevent triggering twice an update
* which is already on its way.
*/
List
<
ConstraintInstance
>
currentlyUpdating
=
new
ArrayList
<>();
/** {@inheritDoc} */
@Override
public
boolean
isUpdating
(
ConstraintInstance
ci
)
{
return
currentlyUpdating
.
contains
(
ci
);
}
/** {@inheritDoc} */
@Override
public
void
markAsUpdating
(
ConstraintInstance
ci
)
{
currentlyUpdating
.
add
(
ci
);
}
}
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