Skip to content

Commit

Permalink
Updated Java formatter: disable join_wrapped_lines to allow method ch…
Browse files Browse the repository at this point in the history
…aining on new lines.
  • Loading branch information
GCHQDeveloper42 committed Jul 5, 2022
1 parent 84241dc commit 365eaad
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 33 deletions.
2 changes: 1 addition & 1 deletion java-formatter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,13 @@ public class MagmaCoreRemoteSparqlDatabase implements MagmaCoreDatabase {
* @param serviceUrl The URL of the SPARQL update endpoint.
*/
public MagmaCoreRemoteSparqlDatabase(final String serviceUrl) {
connection = RDFConnectionRemote.newBuilder().destination(serviceUrl).queryEndpoint("query")
.updateEndpoint("update").triplesFormat(RDFFormat.RDFJSON).build();
connection = RDFConnectionRemote
.newBuilder()
.destination(serviceUrl)
.queryEndpoint("query")
.updateEndpoint("update")
.triplesFormat(RDFFormat.RDFJSON)
.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ private static void occupyHouse(final MagmaCoreService mcService, final List<DbC
final PossibleWorld possibleWorld, final Person person, final FunctionalSystem house, final IRI beginning,
final IRI ending) {

final Map<String, Thing> entities = mcService.findByEntityNameInTransaction(
List.of("CLASS_OF_STATE_OF_PERSON", "STATE_OF_FUNCTIONAL_SYSTEM_DOMESTIC_PROPERTY",
"OCCUPIER_LOCATED_IN_PROPERTY_ROLE", "DOMESTIC_PROPERTY_THAT_IS_OCCUPIED_ROLE",
"OCCUPANT_LOCATED_IN_VOLUME_ENCLOSED_BY_PROPERTY_ASSOCIATION"));
final Map<String, Thing> entities = mcService.findByEntityNameInTransaction(List.of(
"CLASS_OF_STATE_OF_PERSON",
"STATE_OF_FUNCTIONAL_SYSTEM_DOMESTIC_PROPERTY",
"OCCUPIER_LOCATED_IN_PROPERTY_ROLE",
"DOMESTIC_PROPERTY_THAT_IS_OCCUPIED_ROLE",
"OCCUPANT_LOCATED_IN_VOLUME_ENCLOSED_BY_PROPERTY_ASSOCIATION"));

// Find the required classes, kinds, and roles.
final ClassOfStateOfPerson classOfStateOfPerson = (ClassOfStateOfPerson) entities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ public class ExampleIndividuals {
*/
public static DbChangeSet addWholeLifeIndividuals(final MagmaCoreService mcService) {

final Map<String, Thing> entities = mcService.findByEntityNameInTransaction(List.of("KIND_OF_PERSON",
"NATURAL_MEMBER_OF_SOCIETY_ROLE", "KIND_OF_FUNCTIONAL_SYSTEM_DOMESTIC_PROPERTY",
final Map<String, Thing> entities = mcService.findByEntityNameInTransaction(List.of(
"KIND_OF_PERSON",
"NATURAL_MEMBER_OF_SOCIETY_ROLE",
"KIND_OF_FUNCTIONAL_SYSTEM_DOMESTIC_PROPERTY",
"ACCEPTED_PLACE_OF_SEMI_PERMANENT_HABITATION_ROLE"));

// Find the required classes, kinds, and roles.
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/uk/gov/gchq/magmacore/demo/ExampleSigns.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ public static DbTransformation populateExampleData(final MagmaCoreService mcServ
* @return {@link DbChangeSet}.
*/
private static DbChangeSet addSigns(final MagmaCoreService mcService) {
final Map<String, Thing> entities = mcService
.findByEntityNameInTransaction(List.of("URL Pattern", "Description By URL", "English Speakers"));
final Map<String, Thing> entities = mcService.findByEntityNameInTransaction(List.of(
"URL Pattern",
"Description By URL",
"English Speakers"));

// Find the required classes, kinds, and roles.
final Pattern urlPattern = (Pattern) entities.get("URL Pattern");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public void run(final boolean populate) {

// Build and start Fuseki server.
FusekiLogging.setLogging();
FusekiServer.create().port(3330).add("/tdb", tdb.getDataset(), true).start();
FusekiServer
.create()
.port(3330)
.add("/tdb", tdb.getDataset(), true)
.start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ public DbChangeSet(final List<DbDeleteOperation> deletes, final List<DbCreateOpe
*/
@Override
public MagmaCoreService apply(final MagmaCoreService mcService) {
final Function<MagmaCoreService, MagmaCoreService> deleteFunction = deletes.stream()
.map(d -> (Function<MagmaCoreService, MagmaCoreService>) d).reduce(Function::andThen)
final Function<MagmaCoreService, MagmaCoreService> deleteFunction = deletes
.stream()
.map(d -> (Function<MagmaCoreService, MagmaCoreService>) d)
.reduce(Function::andThen)
.orElse(Function.identity());

final Function<MagmaCoreService, MagmaCoreService> createFunction = creates.stream()
.map(c -> (Function<MagmaCoreService, MagmaCoreService>) c).reduce(Function::andThen)
final Function<MagmaCoreService, MagmaCoreService> createFunction = creates
.stream()
.map(c -> (Function<MagmaCoreService, MagmaCoreService>) c)
.reduce(Function::andThen)
.orElse(Function.identity());

mcService.runInTransaction(deleteFunction.andThen(createFunction));
Expand All @@ -63,10 +67,16 @@ public MagmaCoreService apply(final MagmaCoreService mcService) {
* @return The inverted {@link DbChangeSet}.
*/
public static DbChangeSet invert(final DbChangeSet changeSet) {
final List<DbDeleteOperation> newDeletes = changeSet.creates.stream().map(DbCreateOperation::invert)
final List<DbDeleteOperation> newDeletes = changeSet.creates
.stream()
.map(DbCreateOperation::invert)
.collect(Collectors.toList());
final List<DbCreateOperation> newCreates = changeSet.deletes.stream().map(DbDeleteOperation::invert)

final List<DbCreateOperation> newCreates = changeSet.deletes
.stream()
.map(DbDeleteOperation::invert)
.collect(Collectors.toList());

Collections.reverse(newDeletes);
Collections.reverse(newCreates);
return new DbChangeSet(newDeletes, newCreates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public DbTransformation(final List<DbChangeSet> transformations) {
*/
@Override
public MagmaCoreService apply(final MagmaCoreService mcService) {
final Function<MagmaCoreService, MagmaCoreService> transformation = transformations.stream()
final Function<MagmaCoreService, MagmaCoreService> transformation = transformations
.stream()
.map(t -> (Function<MagmaCoreService, MagmaCoreService>) t).reduce(Function::andThen)
.orElse(Function.identity());

Expand All @@ -62,7 +63,10 @@ public MagmaCoreService apply(final MagmaCoreService mcService) {
* @return The inverted {@link DbTransformation}.
*/
public DbTransformation invert() {
final List<DbChangeSet> list = transformations.stream().map(DbChangeSet::invert).collect(Collectors.toList());
final List<DbChangeSet> list = transformations
.stream()
.map(DbChangeSet::invert)
.collect(Collectors.toList());

Collections.reverse(list);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public void testApplyAndInvert() {

// Create operations to add an object with dummy values.
final IRI individualIri = new IRI(TEST_BASE, "individual");
final DbChangeSet createIndividual = new DbChangeSet(List.of(),
List.of(new DbCreateOperation(individualIri, RDFS.RDF_TYPE, HQDM.INDIVIDUAL.getIri()),
new DbCreateOperation(individualIri, HQDM.MEMBER_OF, "classOfIndividual"),
new DbCreateOperation(individualIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));
final DbChangeSet createIndividual = new DbChangeSet(List.of(), List.of(
new DbCreateOperation(individualIri, RDFS.RDF_TYPE, HQDM.INDIVIDUAL.getIri()),
new DbCreateOperation(individualIri, HQDM.MEMBER_OF, "classOfIndividual"),
new DbCreateOperation(individualIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));

// Apply the operations to the dataset.
mcService.runInTransaction(createIndividual);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public void testApplyAndInvert() {
final IRI personIri = new IRI(TEST_BASE, "person");

// Create operations to add an object with dummy values.
final DbChangeSet createIndividual = new DbChangeSet(List.of(),
List.of(new DbCreateOperation(individualIri, RDFS.RDF_TYPE, HQDM.INDIVIDUAL.getIri()),
new DbCreateOperation(individualIri, HQDM.MEMBER_OF, "classOfIndividual"),
new DbCreateOperation(individualIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));

final DbChangeSet createPerson = new DbChangeSet(List.of(),
List.of(new DbCreateOperation(personIri, RDFS.RDF_TYPE, HQDM.PERSON.getIri()),
new DbCreateOperation(personIri, HQDM.MEMBER_OF, "classOfPerson"),
new DbCreateOperation(personIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));
final DbChangeSet createIndividual = new DbChangeSet(List.of(), List.of(
new DbCreateOperation(individualIri, RDFS.RDF_TYPE, HQDM.INDIVIDUAL.getIri()),
new DbCreateOperation(individualIri, HQDM.MEMBER_OF, "classOfIndividual"),
new DbCreateOperation(individualIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));

final DbChangeSet createPerson = new DbChangeSet(List.of(), List.of(
new DbCreateOperation(personIri, RDFS.RDF_TYPE, HQDM.PERSON.getIri()),
new DbCreateOperation(personIri, HQDM.MEMBER_OF, "classOfPerson"),
new DbCreateOperation(personIri, HQDM.PART_OF_POSSIBLE_WORLD, "possible world")));

final DbTransformation transformation = new DbTransformation(List.of(createIndividual, createPerson));

Expand Down

0 comments on commit 365eaad

Please sign in to comment.