Skip to content

Commit 46d3720

Browse files
anki2189sbespalov
authored andcommitted
Connection Contraints from ArtifactCoordinates to GenericArtifactCoordinates
1 parent d800faf commit 46d3720

File tree

2 files changed

+72
-20
lines changed

2 files changed

+72
-20
lines changed

strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/StrongboxSchema.java

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_ID_GROUP;
1111
import static org.carlspring.strongbox.db.schema.Vertices.ARTIFACT_TAG;
1212
import static org.carlspring.strongbox.db.schema.Vertices.GENERIC_ARTIFACT_COORDINATES;
13-
import static org.carlspring.strongbox.db.schema.Vertices.RAW_ARTIFACT_COORDINATES;
1413
import static org.carlspring.strongbox.db.schema.Vertices.MAVEN_ARTIFACT_COORDINATES;
1514
import static org.carlspring.strongbox.db.schema.Vertices.NPM_ARTIFACT_COORDINATES;
1615
import static org.carlspring.strongbox.db.schema.Vertices.NUGET_ARTIFACT_COORDINATES;
1716
import static org.carlspring.strongbox.db.schema.Vertices.PYPI_ARTIFACT_COORDINATES;
17+
import static org.carlspring.strongbox.db.schema.Vertices.RAW_ARTIFACT_COORDINATES;
1818
import static org.carlspring.strongbox.db.schema.Vertices.REMOTE_ARTIFACT;
19+
import static org.carlspring.strongbox.db.schema.Vertices.TRANSACTION_PROPAGATION;
1920
import static org.carlspring.strongbox.db.schema.Vertices.USER;
2021
import static org.janusgraph.core.Multiplicity.MANY2ONE;
2122
import static org.janusgraph.core.Multiplicity.MULTI;
@@ -217,6 +218,7 @@ private void applySchemaChanges(JanusGraphManagement jgm)
217218
createProperties(jgm);
218219

219220
// Vertices
221+
makeVertexLabelIfDoesNotExist(jgm, TRANSACTION_PROPAGATION);
220222
makeVertexLabelIfDoesNotExist(jgm, ARTIFACT);
221223
makeVertexLabelIfDoesNotExist(jgm, REMOTE_ARTIFACT);
222224
makeVertexLabelIfDoesNotExist(jgm, GENERIC_ARTIFACT_COORDINATES);
@@ -254,17 +256,34 @@ private void applyConnectionConstraints(JanusGraphManagement jgm)
254256
jgm.getVertexLabel(ARTIFACT),
255257
jgm.getVertexLabel(ARTIFACT_TAG));
256258

259+
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_GROUP_HAS_ARTIFACTS),
260+
jgm.getVertexLabel(ARTIFACT_ID_GROUP),
261+
jgm.getVertexLabel(ARTIFACT));
262+
257263
jgm.addConnection(jgm.getEdgeLabel(REMOTE_ARTIFACT_INHERIT_ARTIFACT),
258264
jgm.getVertexLabel(REMOTE_ARTIFACT),
259265
jgm.getVertexLabel(ARTIFACT));
260266

261267
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
262-
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES),
268+
jgm.getVertexLabel(RAW_ARTIFACT_COORDINATES),
269+
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
270+
271+
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
272+
jgm.getVertexLabel(NUGET_ARTIFACT_COORDINATES),
273+
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
274+
275+
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
276+
jgm.getVertexLabel(NPM_ARTIFACT_COORDINATES),
277+
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
278+
279+
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
280+
jgm.getVertexLabel(MAVEN_ARTIFACT_COORDINATES),
281+
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
282+
283+
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_COORDINATES_INHERIT_GENERIC_ARTIFACT_COORDINATES),
284+
jgm.getVertexLabel(PYPI_ARTIFACT_COORDINATES),
263285
jgm.getVertexLabel(GENERIC_ARTIFACT_COORDINATES));
264286

265-
jgm.addConnection(jgm.getEdgeLabel(ARTIFACT_GROUP_HAS_ARTIFACTS),
266-
jgm.getVertexLabel(ARTIFACT_ID_GROUP),
267-
jgm.getVertexLabel(ARTIFACT));
268287
}
269288

270289
private void applyPropertyConstraints(JanusGraphManagement jgm)
@@ -286,22 +305,37 @@ private void applyPropertyConstraints(JanusGraphManagement jgm)
286305
addVertexPropertyConstraints(jgm,
287306
REMOTE_ARTIFACT,
288307
"uuid",
289-
"cached");
308+
"cached",
309+
"created");
290310

291311
addVertexPropertyConstraints(jgm,
292312
GENERIC_ARTIFACT_COORDINATES,
293313
"uuid",
294314
"version",
315+
"coordinates.id",
295316
"coordinates.extension",
296-
"coordinates.name");
317+
"coordinates.name",
318+
"coordinates.path",
319+
"coordinates.scope",
320+
"coordinates.groupId",
321+
"coordinates.artifactId",
322+
"coordinates.classifier",
323+
"coordinates.distribution",
324+
"coordinates.build",
325+
"coordinates.abi",
326+
"coordinates.platform",
327+
"coordinates.packaging",
328+
"coordinates.languageImplementationVersion",
329+
"created");
297330

298331
addVertexPropertyConstraints(jgm,
299332
RAW_ARTIFACT_COORDINATES,
300333
"uuid",
301334
"version",
302335
"coordinates.extension",
303336
"coordinates.name",
304-
"coordinates.path");
337+
"coordinates.path",
338+
"created");
305339

306340
addVertexPropertyConstraints(jgm,
307341
MAVEN_ARTIFACT_COORDINATES,
@@ -311,23 +345,26 @@ private void applyPropertyConstraints(JanusGraphManagement jgm)
311345
"coordinates.name",
312346
"coordinates.groupId",
313347
"coordinates.artifactId",
314-
"coordinates.classifier");
348+
"coordinates.classifier",
349+
"created");
315350

316351
addVertexPropertyConstraints(jgm,
317352
NPM_ARTIFACT_COORDINATES,
318353
"uuid",
319354
"version",
320355
"coordinates.extension",
321356
"coordinates.name",
322-
"coordinates.scope");
357+
"coordinates.scope",
358+
"created");
323359

324360
addVertexPropertyConstraints(jgm,
325361
NUGET_ARTIFACT_COORDINATES,
326362
"uuid",
327363
"version",
328364
"coordinates.extension",
329365
"coordinates.name",
330-
"coordinates.id");
366+
"coordinates.id",
367+
"created");
331368

332369
addVertexPropertyConstraints(jgm,
333370
PYPI_ARTIFACT_COORDINATES,
@@ -338,30 +375,34 @@ private void applyPropertyConstraints(JanusGraphManagement jgm)
338375
"coordinates.build",
339376
"coordinates.abi",
340377
"coordinates.platform",
341-
"coordinates.languageImplementationVersion",
342378
"coordinates.packaging",
343-
"coordinates.distribution");
379+
"coordinates.distribution",
380+
"coordinates.languageImplementationVersion",
381+
"created");
344382

345383
addVertexPropertyConstraints(jgm,
346384
ARTIFACT_TAG,
347-
"uuid");
385+
"uuid",
386+
"created");
348387

349388
addVertexPropertyConstraints(jgm,
350389
ARTIFACT_ID_GROUP,
351390
"uuid",
352391
"storageId",
353392
"repositoryId",
354-
"name");
393+
"name",
394+
"created");
355395

356396
addVertexPropertyConstraints(jgm,
357397
USER,
358398
"uuid",
359-
"username",
360399
"password",
361400
"enabled",
362401
"roles",
363402
"securityTokenKey",
364-
"sourceId");
403+
"sourceId",
404+
"created",
405+
"lastUpdated");
365406
}
366407

367408
private void addVertexPropertyConstraints(JanusGraphManagement jgm,

strongbox-db-schema/src/main/java/org/carlspring/strongbox/db/schema/Vertices.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,30 @@ public interface Vertices
44
{
55

66
String ARTIFACT = "Artifact";
7+
78
String REMOTE_ARTIFACT = "RemoteArtifact";
9+
810
String GENERIC_ARTIFACT_COORDINATES = "GenericArtifactCoordinates";
11+
912
String ARTIFACT_COORDINATES = "ArtifactCoordinates";
10-
13+
1114
String RAW_ARTIFACT_COORDINATES = "RawArtifactCoordinates";
15+
1216
String MAVEN_ARTIFACT_COORDINATES = "MavenArtifactCoordinates";
17+
1318
String NPM_ARTIFACT_COORDINATES = "NpmArtifactCoordinates";
19+
1420
String NUGET_ARTIFACT_COORDINATES = "NugetArtifactCoordinates";
21+
1522
String PYPI_ARTIFACT_COORDINATES = "PypiArtifactCoordinates";
23+
1624
String RPM_ARTIFACT_COORDINATES = "RpmArtifactCoordinates";
17-
25+
1826
String ARTIFACT_TAG = "ArtifactTag";
27+
1928
String ARTIFACT_ID_GROUP = "ArtifactIdGroup";
20-
29+
2130
String USER = "User";
31+
32+
String TRANSACTION_PROPAGATION = "TransactionPropagationTestVertex";
2233
}

0 commit comments

Comments
 (0)