├── tests └── src │ ├── test │ └── resources │ │ ├── empty.cyp │ │ ├── statements2.cyp │ │ ├── statements3.cyp │ │ ├── statements.cyp │ │ └── graphgen.cyp │ └── main │ └── java │ └── com │ └── graphaware │ └── test │ └── data │ ├── DatabasePopulator.java │ └── SingleTransactionPopulator.java ├── common └── src │ ├── test │ ├── resources │ │ ├── framework.properties │ │ ├── wrongFramework.properties │ │ └── scanner-test.csv │ └── java │ │ └── com │ │ └── graphaware │ │ └── common │ │ ├── junit │ │ ├── DirtiesNeo4j.java │ │ └── InjectNeo4j.java │ │ └── util │ │ ├── VersionReaderTest.java │ │ └── FileScannerTest.java │ └── main │ ├── resources │ └── framework.properties │ └── java │ └── com │ └── graphaware │ └── common │ ├── policy │ └── inclusion │ │ ├── InclusionPolicy.java │ │ ├── NodeInclusionPolicy.java │ │ ├── NodePropertyInclusionPolicy.java │ │ ├── RelationshipPropertyInclusionPolicy.java │ │ ├── all │ │ ├── IncludeAll.java │ │ ├── IncludeAllProperties.java │ │ ├── IncludeAllNodeProperties.java │ │ ├── IncludeAllNodes.java │ │ ├── IncludeAllRelationships.java │ │ └── IncludeAllRelationshipProperties.java │ │ ├── none │ │ ├── IncludeNone.java │ │ ├── IncludeNoProperties.java │ │ ├── IncludeNoNodes.java │ │ ├── IncludeNoNodeProperties.java │ │ ├── IncludeNoRelationshipProperties.java │ │ ├── IncludeNoRelationships.java │ │ └── IncludeNoEntities.java │ │ ├── ObjectInclusionPolicy.java │ │ ├── BaseNodeInclusionPolicy.java │ │ ├── BaseRelationshipInclusionPolicy.java │ │ ├── PropertyInclusionPolicy.java │ │ ├── composite │ │ ├── CompositeNodePropertyInclusionPolicy.java │ │ ├── CompositeRelationshipPropertyInclusionPolicy.java │ │ └── CompositeNodeInclusionPolicy.java │ │ ├── fluent │ │ ├── IncludeNodeProperties.java │ │ └── IncludeRelationshipProperties.java │ │ ├── EntityInclusionPolicy.java │ │ ├── spel │ │ ├── SpelNodePropertyInclusionPolicy.java │ │ └── SpelRelationshipPropertyInclusionPolicy.java │ │ ├── BaseEntityInclusionPolicy.java │ │ └── RelationshipInclusionPolicy.java │ ├── wrapper │ ├── NodeWrapper.java │ ├── RelationshipWrapper.java │ ├── GraphDatabaseServiceWrapper.java │ ├── EntityWrapper.java │ └── Wrapper.java │ ├── transform │ ├── NodeIdTransformer.java │ ├── RelationshipIdTransformer.java │ ├── NodeTransformer.java │ ├── RelationshipTransformer.java │ ├── Transformer.java │ ├── TrivialNodeIdTransformer.java │ ├── TrivialNodeTransformer.java │ ├── TrivialRelationshipIdTransformer.java │ ├── BaseTrivialIdTransformer.java │ ├── TrivialRelationshipTransformer.java │ ├── BaseIdTransformer.java │ └── IdTransformer.java │ ├── uuid │ ├── UuidGenerator.java │ └── EaioUuidGenerator.java │ ├── expression │ ├── AttachedNodeExpressions.java │ ├── DetachedRelationshipExpressions.java │ ├── DetachedNodeExpressions.java │ └── EntityExpressions.java │ ├── representation │ ├── AttachedNodeProperty.java │ ├── NodeProperty.java │ ├── RelationshipProperty.java │ ├── AttachedRelationshipProperty.java │ ├── Property.java │ ├── AttachedEntity.java │ ├── GraphDetachedNode.java │ └── AttachedRelationship.java │ ├── util │ ├── SameTypePair.java │ ├── VersionReader.java │ ├── Counter.java │ └── BlockingArrayBlockingQueue.java │ ├── description │ ├── BasePartiallyComparable.java │ ├── predicate │ │ ├── Predicate.java │ │ ├── Undefined.java │ │ └── UndefinedValue.java │ ├── MutuallyExclusive.java │ ├── property │ │ ├── DetachedPropertiesDescription.java │ │ └── PropertiesDescription.java │ └── relationship │ │ └── DetachedRelationshipDescription.java │ └── json │ ├── JsonRelationshipTypeAndDirection.java │ └── StringIdJsonNode.java ├── runtime ├── graphaware.conf └── src │ ├── test │ ├── resources │ │ └── com │ │ │ └── graphaware │ │ │ └── tx │ │ │ └── event │ │ │ ├── after-mutation.jpg │ │ │ └── before-mutation.jpg │ └── java │ │ └── com │ │ └── graphaware │ │ └── runtime │ │ ├── config │ │ └── function │ │ │ ├── WrongNodeInclusionPolicy.java │ │ │ ├── SingletonNodeInclusionPolicy.java │ │ │ └── TestNodeInclusionPolicy.java │ │ ├── bootstrap │ │ ├── WritingModuleBootstrapper.java │ │ └── TestModuleBootstrapper.java │ │ └── module │ │ └── thirdparty │ │ └── RememberingWriter.java │ └── main │ └── java │ └── com │ └── graphaware │ └── runtime │ ├── config │ ├── ConfigurationReader.java │ ├── RuntimeConfiguration.java │ ├── DeclaredConfiguration.java │ ├── ModuleConfiguration.java │ └── NullModuleConfiguration.java │ ├── settings │ └── FrameworkSettingsDeclaration.java │ ├── module │ ├── DeliberateTransactionRollbackException.java │ └── thirdparty │ │ └── DefaultThirdPartyIntegrationModule.java │ └── policy │ └── all │ └── IncludeAllBusinessNodeProperties.java ├── examples ├── friendship-strength-counter-module │ └── src │ │ ├── test │ │ └── resources │ │ │ └── neo4j-friendship.conf │ │ └── main │ │ └── java │ │ └── com │ │ └── graphaware │ │ └── example │ │ └── module │ │ ├── Labels.java │ │ ├── Relationships.java │ │ ├── PropertyKeys.java │ │ └── FriendshipStrengthModuleBootstrapper.java ├── change-logger │ └── pom.xml └── friendship-strength-counter │ └── pom.xml ├── .gitignore ├── how-to-release.txt ├── tx-executor ├── src │ ├── main │ │ └── java │ │ │ └── com │ │ │ └── graphaware │ │ │ └── tx │ │ │ └── executor │ │ │ ├── batch │ │ │ ├── NodeUnitOfWork.java │ │ │ ├── BatchTransactionExecutor.java │ │ │ ├── UnitOfWork.java │ │ │ ├── DisposableBatchTransactionExecutor.java │ │ │ └── NoInputBatchTransactionExecutor.java │ │ │ ├── NullItem.java │ │ │ ├── single │ │ │ ├── ExceptionHandlingStrategy.java │ │ │ ├── VoidReturningCallback.java │ │ │ ├── TransactionCallback.java │ │ │ └── RethrowException.java │ │ │ └── input │ │ │ ├── AllNodes.java │ │ │ ├── AllRelationships.java │ │ │ ├── NoInput.java │ │ │ └── AllNodesWithLabel.java │ └── test │ │ └── java │ │ └── com │ │ └── graphaware │ │ └── tx │ │ └── executor │ │ └── batch │ │ ├── CreateNode.java │ │ └── CreateRandomNode.java └── pom.xml ├── tx-api ├── src │ └── main │ │ └── java │ │ └── com │ │ └── graphaware │ │ └── tx │ │ └── event │ │ └── improved │ │ └── data │ │ ├── TransactionDataWrapper.java │ │ └── TransactionDataContainer.java └── pom.xml ├── writer ├── src │ └── main │ │ └── java │ │ └── com │ │ └── graphaware │ │ └── writer │ │ ├── Writer.java │ │ └── thirdparty │ │ ├── CreateOrDelete.java │ │ ├── NodeCreated.java │ │ ├── NodeDeleted.java │ │ ├── WriteOperation.java │ │ ├── ThirdPartyWriter.java │ │ ├── NodeUpdated.java │ │ ├── RelationshipCreated.java │ │ ├── RelationshipDeleted.java │ │ └── Update.java └── pom.xml └── .m2 └── settings.xml /tests/src/test/resources/empty.cyp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /common/src/test/resources/framework.properties: -------------------------------------------------------------------------------- 1 | version=20.1.3 2 | -------------------------------------------------------------------------------- /common/src/main/resources/framework.properties: -------------------------------------------------------------------------------- 1 | version=${version} 2 | -------------------------------------------------------------------------------- /common/src/test/resources/wrongFramework.properties: -------------------------------------------------------------------------------- 1 | wrongVersionKey=20.1.3 2 | -------------------------------------------------------------------------------- /common/src/test/resources/scanner-test.csv: -------------------------------------------------------------------------------- 1 | line0;bla 2 | line1;bla 3 | line2;bla 4 | line3;bla -------------------------------------------------------------------------------- /tests/src/test/resources/statements2.cyp: -------------------------------------------------------------------------------- 1 | CREATE (m:Person {name:'Michal'})-[:WORKS_FOR]->(c:Company {name:'GraphAware'}); 2 | -------------------------------------------------------------------------------- /tests/src/test/resources/statements3.cyp: -------------------------------------------------------------------------------- 1 | MATCH (c:Company {name:'GraphAware'}) 2 | MERGE (d:Person {name:'Daniela'})-[:WORKS_FOR]->(c); -------------------------------------------------------------------------------- /runtime/graphaware.conf: -------------------------------------------------------------------------------- 1 | com.graphaware.module.neo4j.test.1=com.graphaware.runtime.bootstrap.TestModuleBootstrapper 2 | com.graphaware.module.neo4j.test.configKey=configValue 3 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter-module/src/test/resources/neo4j-friendship.conf: -------------------------------------------------------------------------------- 1 | com.graphaware.module.neo4j.friendshipcounter.1=com.graphaware.example.module.FriendshipStrengthModuleBootstrapper -------------------------------------------------------------------------------- /runtime/src/test/resources/com/graphaware/tx/event/after-mutation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphaware/neo4j-framework/HEAD/runtime/src/test/resources/com/graphaware/tx/event/after-mutation.jpg -------------------------------------------------------------------------------- /runtime/src/test/resources/com/graphaware/tx/event/before-mutation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphaware/neo4j-framework/HEAD/runtime/src/test/resources/com/graphaware/tx/event/before-mutation.jpg -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .buildpath 2 | .project 3 | .settings 4 | target/ 5 | .idea/ 6 | *.class 7 | *.iml 8 | *.iws 9 | *.ipr 10 | *.db 11 | .DS_Store 12 | .classpath 13 | server/data/ 14 | .cert 15 | .key 16 | neo4j-home/ 17 | conf/ssl/ 18 | metrics/ 19 | .java-version -------------------------------------------------------------------------------- /common/src/test/java/com/graphaware/common/junit/DirtiesNeo4j.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.common.junit; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Inherited 6 | @Target(ElementType.METHOD) 7 | @Retention(RetentionPolicy.RUNTIME) 8 | public @interface DirtiesNeo4j { 9 | } 10 | -------------------------------------------------------------------------------- /common/src/test/java/com/graphaware/common/junit/InjectNeo4j.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.common.junit; 2 | 3 | import java.lang.annotation.*; 4 | 5 | @Inherited 6 | @Target(ElementType.FIELD) 7 | @Retention(RetentionPolicy.RUNTIME) 8 | public @interface InjectNeo4j { 9 | } 10 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/config/ConfigurationReader.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.runtime.config; 2 | 3 | import org.apache.commons.configuration2.Configuration; 4 | 5 | /** 6 | * Component that knows where and how to find the {@link RuntimeConfiguration}. 7 | */ 8 | public interface ConfigurationReader { 9 | 10 | /** 11 | * @return Runtime {@link Configuration}. 12 | */ 13 | Configuration readConfiguration(); 14 | } 15 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/config/RuntimeConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.runtime.config; 2 | 3 | import com.graphaware.runtime.module.Module; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Reader for GraphAware Framework configuration. 9 | */ 10 | public interface RuntimeConfiguration { 11 | 12 | /** 13 | * Is runtime enabled for the database this configuration is for? 14 | * 15 | * @return true iff enabled. 16 | */ 17 | boolean runtimeEnabled(); 18 | 19 | /** 20 | * Load the runtime configuration. 21 | * 22 | * @return a configuration map, where key is a {@link Module} ID and value is the module's {@link DeclaredConfiguration}. 23 | */ 24 | Map loadConfig(); 25 | } 26 | -------------------------------------------------------------------------------- /common/src/test/java/com/graphaware/common/util/VersionReaderTest.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.common.util; 2 | 3 | 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import static org.junit.jupiter.api.Assertions.*; 8 | 9 | public class VersionReaderTest { 10 | 11 | @Test 12 | public void frameworkVersionIsReadCorrectly() { 13 | assertEquals("20.1.3", VersionReader.getVersion()); 14 | } 15 | 16 | @Test 17 | public void frameworkVersionFileNotExisting() { 18 | assertEquals("Unknown", VersionReader.getVersion("randomFile")); 19 | } 20 | 21 | @Test 22 | public void frameworkVersionWrongFile() { 23 | assertEquals("Unknown", VersionReader.getVersion("wrongFramework.properties")); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/settings/FrameworkSettingsDeclaration.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.runtime.settings; 2 | 3 | import org.neo4j.annotations.service.ServiceProvider; 4 | import org.neo4j.configuration.Description; 5 | import org.neo4j.configuration.SettingsDeclaration; 6 | import org.neo4j.graphdb.config.Setting; 7 | 8 | import static org.neo4j.configuration.SettingImpl.newBuilder; 9 | import static org.neo4j.configuration.SettingValueParsers.BOOL; 10 | import static org.neo4j.configuration.SettingValueParsers.STRING; 11 | 12 | @ServiceProvider 13 | public class FrameworkSettingsDeclaration implements SettingsDeclaration { 14 | 15 | @Description("Name of GraphAware Config File") 16 | public static final Setting ga_config_file_name = newBuilder("com.graphaware.config.file", STRING, "graphaware.conf").build(); 17 | } 18 | -------------------------------------------------------------------------------- /how-to-release.txt: -------------------------------------------------------------------------------- 1 | mvn clean install, make sure it is successful 2 | 3 | search and replace the last snapshot version with the new one 4 | search and replace the last release version with the new one 5 | 6 | mvn release:clean release:prepare 7 | mvn release:perform 8 | 9 | notes: 10 | framework javadoc 11 | 12 | git checkout tags/graphaware-parent-${version} && mvn clean package -DskipTests && mvn javadoc:aggregate && git checkout master 13 | 14 | removing a git tag: 15 | git tag -d graphaware-parent-2.1.7.28 16 | git push origin :refs/tags/graphaware-parent-2.1.7.28 17 | 18 | List of modules to upgrade: 19 | uuid 20 | timetree 21 | expire 22 | reco 23 | triggers 24 | neo4j-to-elasticsearch 25 | nlp 26 | audit 27 | schema 28 | 29 | mvn license:aggregate-add-third-party to generate TPL 30 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/batch/NodeUnitOfWork.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.tx.executor.batch; 2 | 3 | import org.neo4j.graphdb.Node; 4 | import org.neo4j.graphdb.Transaction; 5 | 6 | /** 7 | * {@link UnitOfWork} which takes a Neo4j {@link Node} as input. 8 | */ 9 | public abstract class NodeUnitOfWork implements UnitOfWork { 10 | 11 | @Override 12 | public void execute(Transaction tx, Node input, int batchNumber, int stepNumber) { 13 | execute(tx.getNodeById(input.getId()), batchNumber, stepNumber); 14 | } 15 | 16 | /** 17 | * Execute the unit of work. 18 | * 19 | * @param input to the unit of work. 20 | * @param batchNumber current batch number. 21 | * @param stepNumber current step number. 22 | */ 23 | protected abstract void execute(Node input, int batchNumber, int stepNumber); 24 | } 25 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/InclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | /** 20 | * Marker interface for policies deciding whether to include something or not. 21 | */ 22 | public interface InclusionPolicy { 23 | } 24 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/wrapper/NodeWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.wrapper; 18 | 19 | import org.neo4j.graphdb.Node; 20 | 21 | /** 22 | * A {@link Wrapper} for {@link org.neo4j.graphdb.Node} 23 | */ 24 | public interface NodeWrapper extends Node, EntityWrapper { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/NodeIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Node; 20 | 21 | /** 22 | * {@link IdTransformer} for {@link Node}s. 23 | */ 24 | public interface NodeIdTransformer extends IdTransformer { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/uuid/UuidGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.uuid; 18 | 19 | /** 20 | * A UUID generator. 21 | */ 22 | public interface UuidGenerator { 23 | 24 | /** 25 | * Generate a UUID. 26 | * 27 | * @return the UUID. 28 | */ 29 | String generateUuid(); 30 | } 31 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter-module/src/main/java/com/graphaware/example/module/Labels.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.example.module; 18 | 19 | import org.neo4j.graphdb.Label; 20 | 21 | /** 22 | * All {@link Label}s used in the project. 23 | */ 24 | public enum Labels implements Label{ 25 | 26 | FriendshipCounter 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/NodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * {@link EntityInclusionPolicy} for {@link Node}s. 24 | */ 25 | public interface NodeInclusionPolicy extends EntityInclusionPolicy { 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/RelationshipIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Relationship; 20 | 21 | /** 22 | * {@link IdTransformer} for {@link Relationship}s. 23 | */ 24 | public interface RelationshipIdTransformer extends IdTransformer { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/wrapper/RelationshipWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.wrapper; 18 | 19 | import org.neo4j.graphdb.Relationship; 20 | 21 | /** 22 | * A {@link Wrapper} for {@link org.neo4j.graphdb.Relationship} 23 | */ 24 | public interface RelationshipWrapper extends Relationship, EntityWrapper { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/expression/AttachedNodeExpressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.expression; 18 | 19 | public interface AttachedNodeExpressions extends DetachedNodeExpressions { 20 | 21 | int getDegree(); 22 | 23 | int getDegree(String typeOrDirection); 24 | 25 | int getDegree(String type, String direction); 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/NodePropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.Node; 20 | 21 | /** 22 | * {@link PropertyInclusionPolicy} for {@link Node}s. 23 | */ 24 | public interface NodePropertyInclusionPolicy extends PropertyInclusionPolicy { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/wrapper/GraphDatabaseServiceWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.wrapper; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | 21 | /** 22 | * {@link Wrapper} of the {@link GraphDatabaseService}. 23 | */ 24 | public interface GraphDatabaseServiceWrapper extends Wrapper { 25 | } 26 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/expression/DetachedRelationshipExpressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.expression; 18 | 19 | public interface DetachedRelationshipExpressions extends EntityExpressions { 20 | 21 | String getType(); 22 | 23 | default boolean isType(String type) { 24 | return type.equals(getType()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/batch/BatchTransactionExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | /** 20 | * Component that executes transactional work in batches. 21 | */ 22 | public interface BatchTransactionExecutor { 23 | 24 | /** 25 | * Execute work in batches. 26 | */ 27 | void execute(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter-module/src/main/java/com/graphaware/example/module/Relationships.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.example.module; 18 | 19 | import org.neo4j.graphdb.RelationshipType; 20 | 21 | /** 22 | * All {@link RelationshipType}s used by this project. 23 | */ 24 | public enum Relationships implements RelationshipType { 25 | 26 | FRIEND_OF 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/wrapper/EntityWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.wrapper; 18 | 19 | import org.neo4j.graphdb.Entity; 20 | 21 | /** 22 | * A {@link Wrapper} for {@link org.neo4j.graphdb.Entity}s. 23 | * 24 | * @param type of the wrapped entity. 25 | */ 26 | public interface EntityWrapper extends Entity, Wrapper { 27 | } 28 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/RelationshipPropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.Relationship; 20 | 21 | /** 22 | * {@link PropertyInclusionPolicy} for {@link Relationship}s. 23 | */ 24 | public interface RelationshipPropertyInclusionPolicy extends PropertyInclusionPolicy { 25 | } 26 | -------------------------------------------------------------------------------- /tx-api/src/main/java/com/graphaware/tx/event/improved/data/TransactionDataWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.event.improved.data; 18 | 19 | import com.graphaware.common.wrapper.Wrapper; 20 | import org.neo4j.graphdb.event.TransactionData; 21 | 22 | /** 23 | * {@link Wrapper} of {@link TransactionData}. 24 | */ 25 | public interface TransactionDataWrapper extends Wrapper { 26 | } 27 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/wrapper/Wrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.wrapper; 18 | 19 | /** 20 | * A wrapper (typically a decorator) for an object. 21 | * 22 | * @param type of the object this wrapper wraps. 23 | */ 24 | public interface Wrapper { 25 | 26 | /** 27 | * Get the wrapped instance. 28 | * 29 | * @return wrapped instance. 30 | */ 31 | T getWrapped(); 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/AttachedNodeProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | public class AttachedNodeProperty extends NodeProperty { 20 | 21 | public AttachedNodeProperty(String key, AttachedNode entity) { 22 | super(key, entity); 23 | } 24 | 25 | @Override 26 | public AttachedNode getNode() { 27 | return entity; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/expression/DetachedNodeExpressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.expression; 18 | 19 | import java.util.Arrays; 20 | import java.util.HashSet; 21 | 22 | public interface DetachedNodeExpressions extends EntityExpressions { 23 | 24 | String[] getLabels(); 25 | 26 | default boolean hasLabel(String label) { 27 | return new HashSet<>(Arrays.asList(getLabels())).contains(label); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/NodeProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.graphaware.common.expression.DetachedNodeExpressions; 20 | 21 | public abstract class NodeProperty extends Property { 22 | 23 | protected NodeProperty(String key, T entity) { 24 | super(key, entity); 25 | } 26 | 27 | public abstract T getNode(); 28 | } 29 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter-module/src/main/java/com/graphaware/example/module/PropertyKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.example.module; 18 | 19 | /** 20 | * All property keys used in the project. 21 | */ 22 | public final class PropertyKeys { 23 | 24 | public static final String STRENGTH = "strength"; 25 | public static final String TOTAL_FRIENDSHIP_STRENGTH = "totalFriendshipStrength"; 26 | 27 | private PropertyKeys() { 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/NullItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor; 18 | 19 | /** 20 | * A singleton null object, a placeholder for a value where no value is expected. 21 | */ 22 | public final class NullItem { 23 | 24 | private static final NullItem INSTANCE = new NullItem(); 25 | 26 | public static NullItem getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | private NullItem() { 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/NodeTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.representation.SerializableNode; 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * {@link Transformer} of {@link Node}s. 24 | * 25 | * @param type of the object this transformer transforms to. 26 | */ 27 | public interface NodeTransformer extends Transformer { 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/uuid/EaioUuidGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.uuid; 18 | 19 | import java.util.UUID; 20 | 21 | /** 22 | * UUID Generator using the UUID library from http://johannburkard.de/software/uuid/ 23 | */ 24 | public class EaioUuidGenerator implements UuidGenerator { 25 | 26 | @Override 27 | public String generateUuid() { 28 | UUID uuid = UUID.randomUUID(); 29 | return uuid.toString(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAll.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | import com.graphaware.common.policy.inclusion.ObjectInclusionPolicy; 20 | 21 | /** 22 | * {@link ObjectInclusionPolicy} that includes all objects. 23 | */ 24 | public class IncludeAll implements ObjectInclusionPolicy { 25 | 26 | @Override 27 | public boolean include(T object) { 28 | return true; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/src/main/java/com/graphaware/test/data/DatabasePopulator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.test.data; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | 21 | /** 22 | * A component capable of populating Neo4j for testing purposes. 23 | */ 24 | public interface DatabasePopulator { 25 | 26 | /** 27 | * Populate the given database. 28 | * 29 | * @param database to populate. 30 | */ 31 | void populate(GraphDatabaseService database); 32 | } 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/RelationshipProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.graphaware.common.expression.DetachedRelationshipExpressions; 20 | 21 | public abstract class RelationshipProperty extends Property { 22 | 23 | protected RelationshipProperty(String key, T entity) { 24 | super(key, entity); 25 | } 26 | 27 | public abstract T getRelationship(); 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/RelationshipTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.json.JsonRelationship; 20 | import org.neo4j.graphdb.Relationship; 21 | 22 | /** 23 | * {@link Transformer} of {@link Relationship}s. 24 | * 25 | * @param type of the object this transformer transforms to. 26 | */ 27 | public interface RelationshipTransformer extends Transformer { 28 | } 29 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/AttachedRelationshipProperty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | public class AttachedRelationshipProperty extends RelationshipProperty { 20 | 21 | public AttachedRelationshipProperty(String key, AttachedRelationship entity) { 22 | super(key, entity); 23 | } 24 | 25 | @Override 26 | public AttachedRelationship getRelationship() { 27 | return entity; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/config/function/WrongNodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.config.function; 18 | 19 | import com.graphaware.common.policy.inclusion.BaseNodeInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | public class WrongNodeInclusionPolicy extends BaseNodeInclusionPolicy { 23 | 24 | private WrongNodeInclusionPolicy() { 25 | } 26 | 27 | @Override 28 | public boolean include(Node object) { 29 | return false; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNone.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.ObjectInclusionPolicy; 21 | 22 | /** 23 | * {@link ObjectInclusionPolicy} that excludes everything. 24 | */ 25 | public abstract class IncludeNone implements ObjectInclusionPolicy { 26 | 27 | protected IncludeNone() { 28 | } 29 | 30 | 31 | public final boolean include(T t) { 32 | return false; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/Property.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.graphaware.common.expression.EntityExpressions; 20 | 21 | public abstract class Property { 22 | 23 | private final String key; 24 | protected final T entity; 25 | 26 | protected Property(String key, T entity) { 27 | this.key = key; 28 | this.entity = entity; 29 | } 30 | 31 | public String getKey() { 32 | return key; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/config/DeclaredConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.runtime.config; 2 | 3 | import org.apache.commons.configuration2.Configuration; 4 | 5 | public class DeclaredConfiguration implements Comparable { 6 | 7 | private final int order; 8 | private final String id; 9 | private final String bootstrapper; 10 | private final String database; 11 | private final Configuration config; 12 | 13 | public DeclaredConfiguration(int order, String id, String bootstrapper, String database, Configuration config) { 14 | this.order = order; 15 | this.id = id; 16 | this.bootstrapper = bootstrapper; 17 | this.database = database; 18 | this.config = config; 19 | } 20 | 21 | public int getOrder() { 22 | return order; 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public String getBootstrapper() { 30 | return bootstrapper; 31 | } 32 | 33 | public String getDatabase() { 34 | return database; 35 | } 36 | 37 | public Configuration getConfig() { 38 | return config; 39 | } 40 | 41 | @Override 42 | public int compareTo(DeclaredConfiguration o) { 43 | return Integer.compare(this.order, o.order); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/Writer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer; 18 | 19 | /** 20 | * A writer that writes to a system, which can be a third-party application, or Neo4j itself. 21 | *

22 | * Implementations can choose how they write to the system, but must make sure that tasks that are submitted to it 23 | * run within the context of a transaction. 24 | */ 25 | public interface Writer { 26 | 27 | /** 28 | * Start the writer. 29 | */ 30 | void start(); 31 | 32 | /** 33 | * Stop the writer. 34 | */ 35 | void stop(); 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/util/SameTypePair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.util; 18 | 19 | /** 20 | * An immutable pair of objects, which must be of the same type. 21 | * 22 | * @param type of the objects in the pair. 23 | */ 24 | public class SameTypePair extends Pair { 25 | 26 | /** 27 | * Construct a new pair. 28 | * 29 | * @param first first element, can be null. 30 | * @param second second element, can be null. 31 | */ 32 | public SameTypePair(T first, T second) { 33 | super(first, second); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/ObjectInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | /** 20 | * {@link InclusionPolicy} deciding whether to include an object or not. 21 | * 22 | * @param type of the object to make a decision about. 23 | */ 24 | public interface ObjectInclusionPolicy extends InclusionPolicy { 25 | 26 | /** 27 | * Include the given object? 28 | * 29 | * @param object to check. 30 | * @return true iff the given object should be included. 31 | */ 32 | boolean include(T object); 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/BasePartiallyComparable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description; 18 | 19 | /** 20 | * Base-class for {@link com.graphaware.common.description.predicate.Predicate} implementations. 21 | */ 22 | public abstract class BasePartiallyComparable> { 23 | 24 | /** 25 | * @return this. 26 | */ 27 | protected abstract T self(); 28 | 29 | /** 30 | * @see PartiallyComparable#isMoreSpecificThan(Object). 31 | */ 32 | public boolean isMoreSpecificThan(T other) { 33 | return other.isMoreGeneralThan(self()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAllProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | import com.graphaware.common.policy.inclusion.PropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Entity; 21 | 22 | /** 23 | * Base-class for {@link PropertyInclusionPolicy}s that includes all properties. 24 | */ 25 | public abstract class IncludeAllProperties implements PropertyInclusionPolicy { 26 | 27 | protected IncludeAllProperties() { 28 | } 29 | 30 | @Override 31 | public boolean include(String key, T t) { 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.PropertyInclusionPolicy; 21 | import org.neo4j.graphdb.Entity; 22 | 23 | /** 24 | * {@link PropertyInclusionPolicy} that excludes all properties. 25 | */ 26 | public abstract class IncludeNoProperties implements PropertyInclusionPolicy { 27 | 28 | protected IncludeNoProperties() { 29 | } 30 | 31 | @Override 32 | public final boolean include(String key, T entity) { 33 | return false; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /.m2/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | sonatype-nexus-snapshots 5 | ${env.OSSRH_REPOSITORY_USERNAME} 6 | ${env.OSSRH_REPOSITORY_PASSWORD} 7 | 8 | 9 | sonatype-nexus-staging 10 | ${env.OSSRH_REPOSITORY_USERNAME} 11 | ${env.OSSRH_REPOSITORY_PASSWORD} 12 | 13 | 14 | ossrh 15 | ${env.OSSRH_REPOSITORY_USERNAME} 16 | ${env.OSSRH_REPOSITORY_PASSWORD} 17 | 18 | 19 | neo4j-enterprise 20 | ${env.NEO4J_REPOSITORY_USERNAME} 21 | ${env.NEO4J_REPOSITORY_PASSWORD} 22 | 23 | 24 | 25 | 26 | ossrh 27 | 28 | true 29 | 30 | 31 | ${env.GPG_KEYNAME} 32 | gpg 33 | ${env.GPG_PASSPHRASE} 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/Transformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Entity; 20 | 21 | /** 22 | * A transformer of a {@link Entity}. 23 | * 24 | * @param type of the object this transformer transforms to. 25 | * @param

type of the entity this transformer transforms from. 26 | */ 27 | public interface Transformer { 28 | 29 | /** 30 | * Transforms the given entity. 31 | * 32 | * @param p to transform. Must not be null. 33 | * @return transformed entity. Never null. 34 | */ 35 | R transform(P p); 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/TrivialNodeIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Node; 20 | 21 | /** 22 | * Trivial {@link NodeIdTransformer} that performs no transformation of the ID. Singleton. 23 | */ 24 | public class TrivialNodeIdTransformer extends BaseTrivialIdTransformer implements NodeIdTransformer { 25 | 26 | private static final TrivialNodeIdTransformer INSTANCE = new TrivialNodeIdTransformer(); 27 | 28 | public static TrivialNodeIdTransformer getInstance() { 29 | return INSTANCE; 30 | } 31 | 32 | private TrivialNodeIdTransformer() { 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoNodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | import com.graphaware.common.policy.inclusion.NodeInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * {@link NodeInclusionPolicy} that ignores all nodes. Singleton. 24 | */ 25 | public final class IncludeNoNodes extends IncludeNoEntities implements NodeInclusionPolicy { 26 | 27 | private static final NodeInclusionPolicy INSTANCE = new IncludeNoNodes(); 28 | 29 | public static NodeInclusionPolicy getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | private IncludeNoNodes() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/BaseNodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | import org.neo4j.graphdb.Node; 21 | import org.neo4j.graphdb.Transaction; 22 | 23 | /** 24 | * Base class for {@link NodeInclusionPolicy} implementations. Implements the {@link #getAll(Transaction)} method 25 | * in the most naive way possible. 26 | */ 27 | public abstract class BaseNodeInclusionPolicy extends BaseEntityInclusionPolicy implements NodeInclusionPolicy { 28 | 29 | @Override 30 | protected Iterable doGetAll(Transaction tx) { 31 | return tx.getAllNodes(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/predicate/Predicate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.predicate; 18 | 19 | import com.graphaware.common.description.MutuallyExclusive; 20 | import com.graphaware.common.description.PartiallyComparable; 21 | 22 | /** 23 | * A predicate on beta, i.e. the a property value. 24 | */ 25 | public interface Predicate extends PartiallyComparable, MutuallyExclusive { 26 | 27 | /** 28 | * Evaluate this predicate for beta, i.e., a property value. 29 | * 30 | * @param beta to evaluate this predicate for. 31 | * @return evaluation of this predicate for beta. 32 | */ 33 | boolean evaluate(Object beta); 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/TrivialNodeTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.json.JsonNode; 20 | import com.graphaware.common.json.LongIdJsonNode; 21 | import org.neo4j.graphdb.Node; 22 | 23 | public class TrivialNodeTransformer implements NodeTransformer { 24 | 25 | public static final TrivialNodeTransformer INSTANCE = new TrivialNodeTransformer(); 26 | 27 | public static TrivialNodeTransformer getInstance() { 28 | return INSTANCE; 29 | } 30 | 31 | private TrivialNodeTransformer() { 32 | } 33 | 34 | @Override 35 | public JsonNode transform(Node node) { 36 | return new LongIdJsonNode(node); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/config/function/SingletonNodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.config.function; 18 | 19 | import com.graphaware.common.policy.inclusion.BaseNodeInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | public class SingletonNodeInclusionPolicy extends BaseNodeInclusionPolicy { 23 | 24 | private static final SingletonNodeInclusionPolicy INSTANCE = new SingletonNodeInclusionPolicy(); 25 | 26 | public static SingletonNodeInclusionPolicy getInstance() { 27 | return INSTANCE; 28 | } 29 | 30 | private SingletonNodeInclusionPolicy() { 31 | } 32 | 33 | @Override 34 | public boolean include(Node object) { 35 | return false; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/TrivialRelationshipIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Relationship; 20 | 21 | /** 22 | * Trivial {@link RelationshipIdTransformer} that performs no transformation of the ID. Singleton. 23 | */ 24 | public class TrivialRelationshipIdTransformer extends BaseTrivialIdTransformer implements RelationshipIdTransformer { 25 | 26 | private static final TrivialRelationshipIdTransformer INSTANCE = new TrivialRelationshipIdTransformer(); 27 | 28 | public static TrivialRelationshipIdTransformer getInstance() { 29 | return INSTANCE; 30 | } 31 | 32 | private TrivialRelationshipIdTransformer() { 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/BaseTrivialIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import org.neo4j.graphdb.Entity; 20 | 21 | import static org.springframework.util.Assert.notNull; 22 | 23 | /** 24 | * Abstract base-class for trivial {@link IdTransformer} implementations that in fact perform no transformation. 25 | */ 26 | public abstract class BaseTrivialIdTransformer extends BaseIdTransformer { 27 | 28 | @Override 29 | protected long toExistingGraphId(Long id) { 30 | return id; 31 | } 32 | 33 | @Override 34 | public final Long fromEntity(E entity) { 35 | notNull(entity, "Entity must not be null"); 36 | return entity.getId(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/BaseRelationshipInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | import org.neo4j.graphdb.Relationship; 21 | import org.neo4j.graphdb.Transaction; 22 | 23 | /** 24 | * Base class for {@link RelationshipInclusionPolicy} implementations. Implements the {@link #getAll(Transaction)} method 25 | * in the most naive way possible. 26 | */ 27 | public abstract class BaseRelationshipInclusionPolicy extends BaseEntityInclusionPolicy implements RelationshipInclusionPolicy { 28 | 29 | @Override 30 | protected Iterable doGetAll(Transaction tx) { 31 | return tx.getAllRelationships(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/PropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.Entity; 20 | 21 | /** 22 | * {@link InclusionPolicy} deciding whether to include properties of some {@link Entity} or not. 23 | * 24 | * @param type of the entity. 25 | */ 26 | public interface PropertyInclusionPolicy extends InclusionPolicy { 27 | 28 | /** 29 | * Should a property with the given key of the given entity be included? 30 | * 31 | * @param key of the property. 32 | * @param entity containing the property. 33 | * @return true iff the property should be included. 34 | */ 35 | boolean include(String key, T entity); 36 | } 37 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/bootstrap/WritingModuleBootstrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.bootstrap; 18 | 19 | import com.graphaware.runtime.GraphAwareRuntime; 20 | import com.graphaware.runtime.module.Module; 21 | import com.graphaware.runtime.module.ModuleBootstrapper; 22 | import org.apache.commons.configuration2.Configuration; 23 | import org.neo4j.graphdb.GraphDatabaseService; 24 | 25 | import java.util.Map; 26 | 27 | /** 28 | * {@link ModuleBootstrapper} for {@link TestModule}. 29 | */ 30 | public class WritingModuleBootstrapper implements ModuleBootstrapper { 31 | 32 | @Override 33 | public Module bootstrapModule(String moduleId, Configuration config) { 34 | return new WritingModule(moduleId, config); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAllNodeProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * {@link NodePropertyInclusionPolicy} that includes all node properties. Singleton. 24 | */ 25 | public final class IncludeAllNodeProperties extends IncludeAllProperties implements NodePropertyInclusionPolicy { 26 | 27 | private static final NodePropertyInclusionPolicy INSTANCE = new IncludeAllNodeProperties(); 28 | 29 | public static NodePropertyInclusionPolicy getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | private IncludeAllNodeProperties() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoNodeProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 21 | import org.neo4j.graphdb.Node; 22 | 23 | /** 24 | * {@link NodePropertyInclusionPolicy} that excludes all node properties. Singleton. 25 | */ 26 | public final class IncludeNoNodeProperties extends IncludeNoProperties implements NodePropertyInclusionPolicy { 27 | 28 | private static final NodePropertyInclusionPolicy INSTANCE = new IncludeNoNodeProperties(); 29 | 30 | public static NodePropertyInclusionPolicy getInstance() { 31 | return INSTANCE; 32 | } 33 | 34 | private IncludeNoNodeProperties() { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/single/ExceptionHandlingStrategy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.single; 18 | 19 | /** 20 | * Strategy for dealing with exceptions during transaction execution. 21 | *

22 | * By exception, any {@link RuntimeException} is meant, i.e. both exception in the execution logic 23 | * (e.g. {@link IndexOutOfBoundsException}) and database exception (e.g. {@link org.neo4j.graphdb.TransactionFailureException}). 24 | */ 25 | public interface ExceptionHandlingStrategy { 26 | 27 | /** 28 | * Handle the exception. Handling could mean logging it, re-throwing it, or anything else plus combinations thereof. 29 | * 30 | * @param e to be handled. 31 | */ 32 | void handleException(RuntimeException e); 33 | } 34 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/predicate/Undefined.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.predicate; 18 | 19 | /** 20 | * A {@link Predicate} checking that beta (the property value) is {@link UndefinedValue}. Singleton. 21 | */ 22 | final class Undefined extends EqualTo { 23 | 24 | private static final Undefined INSTANCE = new Undefined(); 25 | 26 | private Undefined() { 27 | super(UndefinedValue.getInstance()); 28 | } 29 | 30 | /** 31 | * Get an instance of this predicate. 32 | * 33 | * @return an instance. 34 | */ 35 | public static Undefined getInstance() { 36 | return INSTANCE; 37 | } 38 | 39 | @Override 40 | public String toString() { 41 | return "=UNDEF"; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/config/ModuleConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.config; 18 | 19 | import com.graphaware.common.policy.inclusion.InclusionPolicies; 20 | import com.graphaware.runtime.module.Module; 21 | 22 | /** 23 | * Encapsulates all configuration of a single {@link Module}. Modules that need no configuration should use {@link NullModuleConfiguration}. 24 | * Otherwise, start with {@link FluentModuleConfiguration}. 25 | */ 26 | public interface ModuleConfiguration { 27 | 28 | /** 29 | * Get the inclusion policies used by this module. If unsure, return {@link com.graphaware.runtime.policy.InclusionPoliciesFactory#allBusiness()}. 30 | * 31 | * @return policies. 32 | */ 33 | InclusionPolicies getInclusionPolicies(); 34 | } 35 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/batch/UnitOfWork.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | import org.neo4j.graphdb.Transaction; 20 | 21 | /** 22 | * A unit of work to be executed as a part of batch execution by {@link BatchTransactionExecutor}. 23 | * 24 | * @param type of the input/parameter for the unit of work. 25 | */ 26 | public interface UnitOfWork { 27 | 28 | /** 29 | * Execute the unit of work. 30 | * 31 | * @param tx in the context of which to execute the work. 32 | * @param input to the unit of work. 33 | * @param batchNumber current batch number. 34 | * @param stepNumber current step number. 35 | */ 36 | void execute(Transaction tx, T input, int batchNumber, int stepNumber); 37 | } 38 | -------------------------------------------------------------------------------- /tx-executor/src/test/java/com/graphaware/tx/executor/batch/CreateNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | import com.graphaware.tx.executor.NullItem; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Transaction; 22 | 23 | /** 24 | * Unit of work that creates an empty node, intended for testing. 25 | */ 26 | public class CreateNode implements UnitOfWork { 27 | private static final CreateNode INSTANCE = new CreateNode(); 28 | 29 | public static CreateNode getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | private CreateNode() { 34 | } 35 | 36 | @Override 37 | public void execute(Transaction database, NullItem input, int batchNumber, int stepNumber) { 38 | database.createNode(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/input/AllNodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.input; 18 | 19 | import com.graphaware.tx.executor.single.TransactionCallback; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Node; 22 | import org.neo4j.graphdb.Transaction; 23 | 24 | /** 25 | * {@link TransactionalInput} returning all nodes in the database. 26 | */ 27 | public final class AllNodes extends TransactionalInput { 28 | 29 | /** 30 | * Create a new input. 31 | * 32 | * @param database to take all nodes from. 33 | * @param batchSize how many nodes in a batch. 34 | */ 35 | public AllNodes(GraphDatabaseService database, int batchSize) { 36 | super(database, batchSize, Transaction::getAllNodes); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/expression/EntityExpressions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.expression; 18 | 19 | import java.util.Map; 20 | 21 | public interface EntityExpressions { 22 | 23 | Map getProperties(); 24 | 25 | default boolean hasProperty(String key) { 26 | return getProperties() != null && getProperties().containsKey(key); 27 | } 28 | 29 | default Object getProperty(String key) { 30 | if (!hasProperty(key)) { 31 | return null; 32 | } 33 | return getProperties().get(key); 34 | } 35 | 36 | default Object getProperty(String key, Object defaultValue) { 37 | if (!hasProperty(key)) { 38 | return defaultValue; 39 | } 40 | 41 | return getProperty(key); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter-module/src/main/java/com/graphaware/example/module/FriendshipStrengthModuleBootstrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.example.module; 18 | 19 | import com.graphaware.runtime.GraphAwareRuntime; 20 | import com.graphaware.runtime.module.Module; 21 | import com.graphaware.runtime.module.ModuleBootstrapper; 22 | import org.apache.commons.configuration2.Configuration; 23 | import org.neo4j.graphdb.GraphDatabaseService; 24 | 25 | import java.util.Map; 26 | 27 | /** 28 | * {@link ModuleBootstrapper} for {@link FriendshipStrengthModule}. 29 | */ 30 | public class FriendshipStrengthModuleBootstrapper implements ModuleBootstrapper { 31 | 32 | @Override 33 | public Module bootstrapModule(String moduleId, Configuration config) { 34 | return new FriendshipStrengthModule(moduleId); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/CreateOrDelete.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedEntity; 20 | import org.neo4j.graphdb.Entity; 21 | 22 | /** 23 | * {@link BaseWriteOperation} representing a create or delete operation. 24 | * 25 | * @param type of the details object. 26 | * @param type of the {@link Entity} that the operation was performed on. 27 | */ 28 | public abstract class CreateOrDelete, T extends Entity> extends BaseWriteOperation { 29 | 30 | /** 31 | * Create the operation. 32 | * 33 | * @param details details about the operation. Must not be null. 34 | */ 35 | protected CreateOrDelete(R details) { 36 | super(details); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/json/JsonRelationshipTypeAndDirection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.json; 18 | 19 | import org.neo4j.graphdb.Direction; 20 | 21 | /** 22 | * JSON-serializable representation of a Neo4j relationship type and direction. Direction defaults to BOTH, type must 23 | * be specified. 24 | */ 25 | public class JsonRelationshipTypeAndDirection { 26 | 27 | private String type; 28 | private Direction direction = Direction.BOTH; 29 | 30 | public String getType() { 31 | return type; 32 | } 33 | 34 | public void setType(String type) { 35 | this.type = type; 36 | } 37 | 38 | public Direction getDirection() { 39 | return direction; 40 | } 41 | 42 | public void setDirection(Direction direction) { 43 | this.direction = direction; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/single/VoidReturningCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.single; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | import org.neo4j.graphdb.Transaction; 21 | 22 | /** 23 | * A {@link TransactionCallback} returning void. 24 | */ 25 | public abstract class VoidReturningCallback implements TransactionCallback { 26 | 27 | @Override 28 | public final Void doInTransaction(Transaction database) { 29 | doInTx(database); 30 | return null; 31 | } 32 | 33 | /** 34 | * Perform the work. This method is guaranteed to run in the context of a transaction. 35 | * 36 | * @param database on which to perform work and against which the transaction is running. 37 | */ 38 | protected abstract void doInTx(Transaction database); 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAllNodes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.BaseNodeInclusionPolicy; 21 | import com.graphaware.common.policy.inclusion.NodeInclusionPolicy; 22 | import org.neo4j.graphdb.Node; 23 | 24 | /** 25 | * {@link NodeInclusionPolicy} that includes all nodes. Singleton. 26 | */ 27 | public final class IncludeAllNodes extends BaseNodeInclusionPolicy { 28 | 29 | private static final NodeInclusionPolicy INSTANCE = new IncludeAllNodes(); 30 | 31 | public static NodeInclusionPolicy getInstance() { 32 | return INSTANCE; 33 | } 34 | 35 | private IncludeAllNodes() { 36 | } 37 | 38 | @Override 39 | public boolean include(Node object) { 40 | return true; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/composite/CompositeNodePropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.composite; 18 | 19 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * {@link CompositePropertyInclusionPolicy} for {@link Node}s. 24 | */ 25 | public final class CompositeNodePropertyInclusionPolicy extends CompositePropertyInclusionPolicy implements NodePropertyInclusionPolicy { 26 | 27 | public static CompositeNodePropertyInclusionPolicy of(NodePropertyInclusionPolicy... policies) { 28 | return new CompositeNodePropertyInclusionPolicy(policies); 29 | } 30 | 31 | private CompositeNodePropertyInclusionPolicy(NodePropertyInclusionPolicy[] policies) { 32 | super(policies); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/util/VersionReader.java: -------------------------------------------------------------------------------- 1 | package com.graphaware.common.util; 2 | 3 | import java.io.InputStream; 4 | import java.util.Properties; 5 | 6 | /** 7 | * Reads version from property file. 8 | * 9 | * Version is replaced in the property file by maven to match the version in POM. 10 | */ 11 | public class VersionReader { 12 | 13 | private static final String UNKNOWN = "Unknown"; 14 | private static final String DEFAULT_VERSION_FILE = "framework.properties"; 15 | private static final String VERSION_PROPERTY = "version"; 16 | 17 | /** 18 | * Reads the version from the default file. 19 | * 20 | * The default file is the one, where maven sets current version. 21 | * 22 | * The version is not cached and every call of this method results in a file read. 23 | * 24 | * @return current version of the project as defined in the POM 25 | */ 26 | public static String getVersion(){ 27 | return getVersion(DEFAULT_VERSION_FILE); 28 | } 29 | 30 | /** 31 | * Reads version from different file 32 | * 33 | * Mainly for testing purposes 34 | * 35 | * @param fileName file to read from 36 | * @return version of the project 37 | */ 38 | public static String getVersion(String fileName) { 39 | Properties prop = new Properties(); 40 | try (InputStream in = VersionReader.class.getClassLoader().getResourceAsStream(fileName)) { 41 | prop.load(in); 42 | } catch (Exception e) { 43 | return UNKNOWN; 44 | } 45 | return prop.getProperty(VERSION_PROPERTY, UNKNOWN); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAllRelationships.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | import com.graphaware.common.policy.inclusion.RelationshipInclusionPolicy; 20 | import org.neo4j.graphdb.Relationship; 21 | 22 | /** 23 | * {@link RelationshipInclusionPolicy} that includes all relationships. Singleton. 24 | */ 25 | public final class IncludeAllRelationships extends RelationshipInclusionPolicy.Adapter { 26 | 27 | private static final RelationshipInclusionPolicy INSTANCE = new IncludeAllRelationships(); 28 | 29 | public static RelationshipInclusionPolicy getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | private IncludeAllRelationships() { 34 | } 35 | 36 | @Override 37 | public boolean include(Relationship object) { 38 | return true; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/NodeCreated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.GraphDetachedNode; 21 | import org.neo4j.graphdb.Node; 22 | 23 | /** 24 | * {@link WriteOperation} representing a {@link Node} being created. 25 | */ 26 | public class NodeCreated extends CreateOrDelete, Node> { 27 | 28 | /** 29 | * Create the operation. 30 | * 31 | * @param createdNode representation of the created node. Must not be null. 32 | */ 33 | public NodeCreated(DetachedNode createdNode) { 34 | super(createdNode); 35 | } 36 | 37 | @Override 38 | public OperationType getType() { 39 | return OperationType.NODE_CREATED; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/NodeDeleted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.GraphDetachedNode; 21 | import org.neo4j.graphdb.Node; 22 | 23 | /** 24 | * {@link WriteOperation} representing a {@link Node} being deleted. 25 | */ 26 | public class NodeDeleted extends CreateOrDelete, Node> { 27 | 28 | /** 29 | * Create the operation. 30 | * 31 | * @param deletedNode representation of the deleted node. Must not be null. 32 | */ 33 | public NodeDeleted(DetachedNode deletedNode) { 34 | super(deletedNode); 35 | } 36 | 37 | @Override 38 | public OperationType getType() { 39 | return OperationType.NODE_DELETED; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/TrivialRelationshipTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.json.JsonRelationship; 20 | import com.graphaware.common.json.LongIdJsonRelationship; 21 | import org.neo4j.graphdb.Relationship; 22 | 23 | public class TrivialRelationshipTransformer implements RelationshipTransformer { 24 | 25 | public static final TrivialRelationshipTransformer INSTANCE = new TrivialRelationshipTransformer(); 26 | 27 | public static TrivialRelationshipTransformer getInstance() { 28 | return INSTANCE; 29 | } 30 | 31 | private TrivialRelationshipTransformer() { 32 | } 33 | 34 | @Override 35 | public JsonRelationship transform(Relationship relationship) { 36 | return new LongIdJsonRelationship(relationship); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/all/IncludeAllRelationshipProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.all; 18 | 19 | import com.graphaware.common.policy.inclusion.RelationshipPropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Relationship; 21 | 22 | /** 23 | * {@link RelationshipPropertyInclusionPolicy} that includes all relationship properties. Singleton. 24 | */ 25 | public final class IncludeAllRelationshipProperties extends IncludeAllProperties implements RelationshipPropertyInclusionPolicy { 26 | 27 | private static final RelationshipPropertyInclusionPolicy INSTANCE = new IncludeAllRelationshipProperties(); 28 | 29 | public static RelationshipPropertyInclusionPolicy getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | protected IncludeAllRelationshipProperties() { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoRelationshipProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.RelationshipPropertyInclusionPolicy; 21 | import org.neo4j.graphdb.Relationship; 22 | 23 | /** 24 | * {@link RelationshipPropertyInclusionPolicy} that ignores all relationships properties. Singleton. 25 | */ 26 | public final class IncludeNoRelationshipProperties extends IncludeNoProperties implements RelationshipPropertyInclusionPolicy { 27 | 28 | private static final RelationshipPropertyInclusionPolicy INSTANCE = new IncludeNoRelationshipProperties(); 29 | 30 | public static RelationshipPropertyInclusionPolicy getInstance() { 31 | return INSTANCE; 32 | } 33 | 34 | private IncludeNoRelationshipProperties() { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/WriteOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import java.io.Serializable; 20 | 21 | /** 22 | * Representation of a database write operation. 23 | * 24 | * @param type of the object that provides details about the operation. 25 | */ 26 | public interface WriteOperation extends Serializable { 27 | 28 | enum OperationType { 29 | NODE_CREATED, 30 | NODE_UPDATED, 31 | NODE_DELETED, 32 | RELATIONSHIP_CREATED, 33 | RELATIONSHIP_UPDATED, 34 | RELATIONSHIP_DELETED 35 | } 36 | 37 | /** 38 | * @return type of the operation. Never null. 39 | */ 40 | OperationType getType(); 41 | 42 | /** 43 | * @return details about the object the operation was performed on. 44 | */ 45 | T getDetails(); 46 | } 47 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/input/AllRelationships.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.input; 18 | 19 | import com.graphaware.tx.executor.single.TransactionCallback; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Relationship; 22 | import org.neo4j.graphdb.Transaction; 23 | 24 | /** 25 | * {@link TransactionalInput} returning all relationships in the database. 26 | */ 27 | public final class AllRelationships extends TransactionalInput { 28 | 29 | /** 30 | * Create a new input. 31 | * 32 | * @param database to take all relationships from. 33 | * @param batchSize how many relationships in a batch. 34 | */ 35 | public AllRelationships(GraphDatabaseService database, int batchSize) { 36 | super(database, batchSize, Transaction::getAllRelationships); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/module/thirdparty/RememberingWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.module.thirdparty; 18 | 19 | import com.graphaware.writer.thirdparty.BaseThirdPartyWriter; 20 | import com.graphaware.writer.thirdparty.WriteOperation; 21 | 22 | import java.util.Collection; 23 | import java.util.LinkedList; 24 | import java.util.List; 25 | 26 | /** 27 | * Writer for testing. Remembers what's been submitted to it. 28 | */ 29 | class RememberingWriter extends BaseThirdPartyWriter { 30 | 31 | List>> remembered = new LinkedList<>(); 32 | 33 | @Override 34 | protected void processOperations(List>> operations) { 35 | remembered.addAll(operations); 36 | } 37 | 38 | public List>> getRemembered() { 39 | return remembered; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tx-api/src/main/java/com/graphaware/tx/event/improved/data/TransactionDataContainer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.event.improved.data; 18 | 19 | import org.neo4j.graphdb.Transaction; 20 | import org.neo4j.graphdb.event.TransactionData; 21 | 22 | /** 23 | * A component that contains {@link NodeTransactionData} and {@link RelationshipTransactionData}. 24 | */ 25 | public interface TransactionDataContainer extends TransactionDataWrapper { 26 | 27 | Transaction getTransaction(); 28 | 29 | /** 30 | * Get contained node transaction data. 31 | * 32 | * @return node transaction data. 33 | */ 34 | NodeTransactionData getNodeTransactionData(); 35 | 36 | /** 37 | * Get contained relationship transaction data. 38 | * 39 | * @return relationship transaction data. 40 | */ 41 | RelationshipTransactionData getRelationshipTransactionData(); 42 | } 43 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/input/NoInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.input; 18 | 19 | import com.graphaware.tx.executor.NullItem; 20 | import com.graphaware.tx.executor.batch.BatchTransactionExecutor; 21 | import com.graphaware.tx.executor.batch.UnitOfWork; 22 | 23 | /** 24 | * Dummy generated input that is intended for {@link BatchTransactionExecutor}s that use {@link UnitOfWork} but generate 25 | * their own input. Thus the only thing this class does is signal when enough units of work have been executed by returning 26 | * {@code false} from {@link #hasNext()}. 27 | */ 28 | public final class NoInput extends GeneratedInput { 29 | 30 | public NoInput(int numberOfItems) { 31 | super(numberOfItems); 32 | } 33 | 34 | @Override 35 | protected NullItem generate() { 36 | return NullItem.getInstance(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/predicate/UndefinedValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.predicate; 18 | 19 | /** 20 | * Singleton representing an undefined value. 21 | */ 22 | final class UndefinedValue { 23 | 24 | private static final UndefinedValue INSTANCE = new UndefinedValue(); 25 | 26 | private UndefinedValue() { 27 | } 28 | 29 | static UndefinedValue getInstance() { 30 | return INSTANCE; 31 | } 32 | 33 | @Override 34 | public boolean equals(Object obj) { 35 | if (this == obj) return true; 36 | if (obj == null || getClass() != obj.getClass()) return false; 37 | return true; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | return "undef".hashCode(); 43 | } 44 | 45 | @Override 46 | public String toString() { 47 | return "UNDEF"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/src/main/java/com/graphaware/test/data/SingleTransactionPopulator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.test.data; 18 | 19 | import org.neo4j.graphdb.GraphDatabaseService; 20 | import org.neo4j.graphdb.Transaction; 21 | 22 | /** 23 | * A {@link com.graphaware.test.data.DatabasePopulator} that populates Neo4j using a single transaction. 24 | */ 25 | public abstract class SingleTransactionPopulator implements DatabasePopulator { 26 | 27 | @Override 28 | public final void populate(GraphDatabaseService database) { 29 | try (Transaction tx = database.beginTx()) { 30 | doPopulate(database); 31 | tx.commit(); 32 | } 33 | } 34 | 35 | /** 36 | * Perform the database population. No need to handle transactions. 37 | * 38 | * @param database to populate. 39 | */ 40 | protected abstract void doPopulate(GraphDatabaseService database); 41 | } 42 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/bootstrap/TestModuleBootstrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.bootstrap; 18 | 19 | import com.graphaware.runtime.GraphAwareRuntime; 20 | import com.graphaware.runtime.module.ModuleBootstrapper; 21 | import com.graphaware.runtime.module.Module; 22 | import org.apache.commons.configuration2.Configuration; 23 | import org.neo4j.configuration.SettingImpl; 24 | import org.neo4j.configuration.SettingValueParsers; 25 | import org.neo4j.graphdb.GraphDatabaseService; 26 | import org.neo4j.graphdb.config.Setting; 27 | 28 | import java.util.Map; 29 | 30 | /** 31 | * {@link ModuleBootstrapper} for {@link TestModule}. 32 | */ 33 | public class TestModuleBootstrapper implements ModuleBootstrapper { 34 | 35 | @Override 36 | public Module bootstrapModule(String moduleId, Configuration config) { 37 | return new TestModule(moduleId, config); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/MutuallyExclusive.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description; 18 | 19 | /** 20 | * Component that can determine, whether it is mutually exclusive with another instance. 21 | *

22 | * In the context of this project, mutually exclusive instances are instances that are {@link PartiallyComparable} 23 | * and do not share a common more specific instance in the lattice formed by the partial order. 24 | * 25 | * @param type of object this can be mutually exclusive with. 26 | */ 27 | public interface MutuallyExclusive { 28 | 29 | /** 30 | * Is this instance mutually exclusive with the given other instance? This method is reflexive. 31 | * 32 | * @param other to check mutual exclusivity against. 33 | * @return true iff this and the other are mutually exclusive. 34 | */ 35 | boolean isMutuallyExclusive(T other); 36 | } 37 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/single/TransactionCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.single; 18 | 19 | import org.neo4j.graphdb.Transaction; 20 | 21 | /** 22 | * A specification of work to be executed within a transaction. 23 | * 24 | * @param type of what is returned in case of a successful TX execution. 25 | */ 26 | public interface TransactionCallback { 27 | 28 | /** 29 | * Perform the work. This method is guaranteed to run in the context of a transaction. 30 | * 31 | * @param database on which to perform work and against which the transaction is running. 32 | * @return result of the transaction, can be null in case of a failure (or when no result is expected, in which case 33 | * the generic type of the implementation should be {@link Void}. 34 | */ 35 | T doInTransaction(final Transaction database) throws Exception; 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/fluent/IncludeNodeProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.fluent; 18 | 19 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | /** 23 | * An implementation of {@link NodePropertyInclusionPolicy} that is entirely configurable using its fluent interface. 24 | */ 25 | public class IncludeNodeProperties extends BaseIncludeProperties implements NodePropertyInclusionPolicy { 26 | 27 | public static IncludeNodeProperties all() { 28 | return new IncludeNodeProperties(null); 29 | } 30 | 31 | protected IncludeNodeProperties(String key) { 32 | super(key); 33 | } 34 | 35 | @Override 36 | protected IncludeNodeProperties newInstance(String key) { 37 | return new IncludeNodeProperties(key); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/ThirdPartyWriter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.writer.Writer; 20 | 21 | import java.util.Collection; 22 | 23 | /** 24 | * A {@link Writer} to a third-party system. 25 | */ 26 | public interface ThirdPartyWriter extends Writer { 27 | 28 | /** 29 | * Write an operation. 30 | * 31 | * @param operation to write. Must not be null. 32 | * @param id for logging purposes. Must not be null. 33 | */ 34 | void write(WriteOperation operation, String id); 35 | 36 | /** 37 | * Write a collection of operations. 38 | * 39 | * @param operations to write. Must not be null. 40 | * @param id for logging purposes. Must not be null. 41 | */ 42 | void write(Collection> operations, String id); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/composite/CompositeRelationshipPropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.composite; 18 | 19 | import com.graphaware.common.policy.inclusion.RelationshipPropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Relationship; 21 | 22 | /** 23 | * {@link CompositePropertyInclusionPolicy} for {@link Relationship}s. 24 | */ 25 | public final class CompositeRelationshipPropertyInclusionPolicy extends CompositePropertyInclusionPolicy implements RelationshipPropertyInclusionPolicy { 26 | 27 | public static CompositeRelationshipPropertyInclusionPolicy of(RelationshipPropertyInclusionPolicy... policies) { 28 | return new CompositeRelationshipPropertyInclusionPolicy(policies); 29 | } 30 | 31 | private CompositeRelationshipPropertyInclusionPolicy(RelationshipPropertyInclusionPolicy[] policies) { 32 | super(policies); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoRelationships.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | 20 | import com.graphaware.common.policy.inclusion.RelationshipInclusionPolicy; 21 | import org.neo4j.graphdb.Node; 22 | import org.neo4j.graphdb.Relationship; 23 | 24 | /** 25 | * {@link RelationshipInclusionPolicy} that ignores all relationships. Singleton. 26 | */ 27 | public final class IncludeNoRelationships extends IncludeNoEntities implements RelationshipInclusionPolicy { 28 | 29 | private static final RelationshipInclusionPolicy INSTANCE = new IncludeNoRelationships(); 30 | 31 | public static RelationshipInclusionPolicy getInstance() { 32 | return INSTANCE; 33 | } 34 | 35 | private IncludeNoRelationships() { 36 | } 37 | 38 | @Override 39 | public boolean include(Relationship relationship, Node pointOfView) { 40 | return false; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/EntityInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | 20 | import org.neo4j.graphdb.Entity; 21 | import org.neo4j.graphdb.Transaction; 22 | 23 | /** 24 | * {@link ObjectInclusionPolicy} for {@link Entity}s. 25 | */ 26 | public interface EntityInclusionPolicy extends ObjectInclusionPolicy { 27 | 28 | /** 29 | * Get all {@link Entity}s matching the policy from the database. This can be a naive implementation 30 | * retrieving all {@link Entity}s and calling the {@link #include(Object)} method for each one of them, 31 | * but it could also be more clever than that and directly retrieve the included {@link Entity}s from an 32 | * index, by label, etc. 33 | * 34 | * @param tx to retrieve the {@link Entity}s from. 35 | * @return all {@link Entity}s matching the policy. 36 | */ 37 | Iterable getAll(Transaction tx); 38 | } 39 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/none/IncludeNoEntities.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.none; 18 | 19 | import com.graphaware.common.policy.inclusion.BaseEntityInclusionPolicy; 20 | import com.graphaware.common.policy.inclusion.EntityInclusionPolicy; 21 | import org.neo4j.graphdb.GraphDatabaseService; 22 | import org.neo4j.graphdb.Entity; 23 | import org.neo4j.graphdb.Transaction; 24 | import org.neo4j.internal.helpers.collection.Iterables; 25 | 26 | /** 27 | * {@link EntityInclusionPolicy} that ignores all entities. 28 | */ 29 | public abstract class IncludeNoEntities extends BaseEntityInclusionPolicy { 30 | 31 | protected IncludeNoEntities() { 32 | } 33 | 34 | @Override 35 | public final boolean include(T entity) { 36 | return false; 37 | } 38 | 39 | @Override 40 | protected Iterable doGetAll(Transaction tx) { 41 | return Iterables.empty(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/BaseIdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.representation.DetachedEntity; 20 | import org.neo4j.graphdb.Entity; 21 | 22 | /** 23 | * Abstract base-class for {@link IdTransformer} implementations. 24 | * 25 | * @param custom ID type. 26 | * @param entity type. 27 | */ 28 | public abstract class BaseIdTransformer implements IdTransformer { 29 | 30 | @Override 31 | public final long toGraphId(ID id) { 32 | if (id == null) { 33 | return DetachedEntity.NEW; 34 | } 35 | 36 | return toExistingGraphId(id); 37 | } 38 | 39 | /** 40 | * Transform a custom ID to internal Neo4j ID. 41 | * 42 | * @param id to transform. Will never be null. 43 | * @return internal Neo4j ID. 44 | */ 45 | protected abstract long toExistingGraphId(ID id); 46 | } 47 | -------------------------------------------------------------------------------- /tx-executor/src/test/java/com/graphaware/tx/executor/batch/CreateRandomNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | import com.graphaware.tx.executor.NullItem; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Node; 22 | import org.neo4j.graphdb.Transaction; 23 | 24 | import java.util.UUID; 25 | 26 | /** 27 | * Unit of work that creates a node with a random name, intended for testing. 28 | */ 29 | public class CreateRandomNode implements UnitOfWork { 30 | private static final CreateRandomNode INSTANCE = new CreateRandomNode(); 31 | 32 | public static CreateRandomNode getInstance() { 33 | return INSTANCE; 34 | } 35 | 36 | private CreateRandomNode() { 37 | } 38 | 39 | @Override 40 | public void execute(Transaction database, NullItem input, int batchNumber, int stepNumber) { 41 | Node node = database.createNode(); 42 | node.setProperty("name", UUID.randomUUID()); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/batch/DisposableBatchTransactionExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | import java.util.concurrent.atomic.AtomicBoolean; 20 | 21 | /** 22 | * {@link BatchTransactionExecutor} which expects the {@link #execute()} method to only ever be called at most once. 23 | * After that, it must be discarded. 24 | */ 25 | public abstract class DisposableBatchTransactionExecutor implements BatchTransactionExecutor { 26 | 27 | private final AtomicBoolean alreadyExecuted = new AtomicBoolean(false); 28 | 29 | @Override 30 | public final void execute() { 31 | if (alreadyExecuted.compareAndSet(false, true)) { 32 | doExecute(); 33 | } else { 34 | throw new IllegalStateException("DisposableBatchExecutor must only ever be executed once!"); 35 | } 36 | } 37 | 38 | /** 39 | * Execute work in batches. 40 | */ 41 | protected abstract void doExecute(); 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/fluent/IncludeRelationshipProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.fluent; 18 | 19 | import com.graphaware.common.policy.inclusion.RelationshipPropertyInclusionPolicy; 20 | import org.neo4j.graphdb.Relationship; 21 | 22 | /** 23 | * An implementation of {@link RelationshipPropertyInclusionPolicy} that is entirely configurable using its fluent interface. 24 | */ 25 | public class IncludeRelationshipProperties extends BaseIncludeProperties implements RelationshipPropertyInclusionPolicy { 26 | 27 | public static IncludeRelationshipProperties all() { 28 | return new IncludeRelationshipProperties(null); 29 | } 30 | 31 | protected IncludeRelationshipProperties(String key) { 32 | super(key); 33 | } 34 | 35 | @Override 36 | protected IncludeRelationshipProperties newInstance(String key) { 37 | return new IncludeRelationshipProperties(key); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/module/DeliberateTransactionRollbackException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.module; 18 | 19 | /** 20 | * {@link RuntimeException} indicating that a module wishes to prevent a transaction from committing. 21 | */ 22 | public class DeliberateTransactionRollbackException extends RuntimeException { 23 | 24 | public DeliberateTransactionRollbackException() { 25 | } 26 | 27 | public DeliberateTransactionRollbackException(String message) { 28 | super(message); 29 | } 30 | 31 | public DeliberateTransactionRollbackException(String message, Throwable cause) { 32 | super(message, cause); 33 | } 34 | 35 | public DeliberateTransactionRollbackException(Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | public DeliberateTransactionRollbackException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { 40 | super(message, cause, enableSuppression, writableStackTrace); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/composite/CompositeNodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.composite; 18 | 19 | import com.graphaware.common.policy.inclusion.NodeInclusionPolicy; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Node; 22 | import org.neo4j.graphdb.Transaction; 23 | 24 | /** 25 | * {@link CompositeEntityInclusionPolicy} for {@link Node}s. 26 | */ 27 | public final class CompositeNodeInclusionPolicy extends CompositeEntityInclusionPolicy implements NodeInclusionPolicy { 28 | 29 | public static CompositeNodeInclusionPolicy of(NodeInclusionPolicy... policies) { 30 | return new CompositeNodeInclusionPolicy(policies); 31 | } 32 | 33 | private CompositeNodeInclusionPolicy(NodeInclusionPolicy[] policies) { 34 | super(policies); 35 | } 36 | 37 | @Override 38 | protected Iterable doGetAll(Transaction tx) { 39 | return tx.getAllNodes(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /common/src/test/java/com/graphaware/common/util/FileScannerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.util; 18 | 19 | import org.junit.jupiter.api.Test; 20 | 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | import static org.junit.jupiter.api.Assertions.assertEquals; 25 | 26 | public class FileScannerTest { 27 | 28 | @Test 29 | public void verifyCorrectNumberOfScannedLines() throws IOException { 30 | assertEquals(4, FileScanner.produceLines(FileScannerTest.class.getClassLoader().getResourceAsStream("scanner-test.csv"), 0).size()); 31 | } 32 | 33 | @Test 34 | public void verifyCorrectlyScannedLines() throws IOException { 35 | List lines = FileScanner.produceLines(FileScannerTest.class.getClassLoader().getResourceAsStream("scanner-test.csv"),1); 36 | 37 | assertEquals(3, lines.size()); 38 | assertEquals("line1;bla", lines.get(0)); 39 | assertEquals("line2;bla", lines.get(1)); 40 | assertEquals("line3;bla", lines.get(2)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/NodeUpdated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.GraphDetachedNode; 21 | import org.neo4j.graphdb.Node; 22 | 23 | /** 24 | * {@link WriteOperation} representing a {@link Node} being updated. 25 | */ 26 | public class NodeUpdated extends Update, Node> { 27 | 28 | /** 29 | * Create the operation. 30 | * 31 | * @param previous representation of the previous state of the updated {@link Node}. Must not be null. 32 | * @param current representation of the current state of the updated {@link Node}. Must not be null. 33 | */ 34 | public NodeUpdated(DetachedNode previous, DetachedNode current) { 35 | super(previous, current); 36 | } 37 | 38 | @Override 39 | public OperationType getType() { 40 | return OperationType.NODE_UPDATED; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /runtime/src/test/java/com/graphaware/runtime/config/function/TestNodeInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.config.function; 18 | 19 | import com.graphaware.common.policy.inclusion.BaseNodeInclusionPolicy; 20 | import org.neo4j.graphdb.Node; 21 | 22 | public class TestNodeInclusionPolicy extends BaseNodeInclusionPolicy { 23 | 24 | private final String someField = "test"; 25 | 26 | public TestNodeInclusionPolicy() { 27 | } 28 | 29 | @Override 30 | public boolean include(Node object) { 31 | return false; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (o == null || getClass() != o.getClass()) return false; 38 | 39 | TestNodeInclusionPolicy that = (TestNodeInclusionPolicy) o; 40 | 41 | if (!someField.equals(that.someField)) return false; 42 | 43 | return true; 44 | } 45 | 46 | @Override 47 | public int hashCode() { 48 | return someField.hashCode(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/spel/SpelNodePropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.spel; 18 | 19 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 20 | import com.graphaware.common.representation.AttachedNode; 21 | import com.graphaware.common.representation.AttachedNodeProperty; 22 | import com.graphaware.common.representation.NodeProperty; 23 | import org.neo4j.graphdb.Node; 24 | 25 | /** 26 | * {@link NodePropertyInclusionPolicy} based on a SPEL expression. The expression can use methods defined in 27 | * {@link NodeProperty}. 28 | */ 29 | public class SpelNodePropertyInclusionPolicy extends SpelInclusionPolicy implements NodePropertyInclusionPolicy { 30 | 31 | public SpelNodePropertyInclusionPolicy(String expression) { 32 | super(expression); 33 | } 34 | 35 | @Override 36 | public boolean include(String key, Node node) { 37 | return (Boolean) exp.getValue(new AttachedNodeProperty(key, new AttachedNode(node))); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/BaseEntityInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | import org.neo4j.graphdb.Entity; 20 | import org.neo4j.graphdb.Transaction; 21 | import org.neo4j.internal.helpers.collection.FilteringIterable; 22 | 23 | /** 24 | * Base class for {@link EntityInclusionPolicy} implementations that implement the {@link #getAll(Transaction)} 25 | * method in a naive way. 26 | * 27 | * @param 28 | */ 29 | public abstract class BaseEntityInclusionPolicy implements EntityInclusionPolicy { 30 | 31 | @Override 32 | public Iterable getAll(Transaction tx) { 33 | return new FilteringIterable<>(doGetAll(tx), this::include); 34 | } 35 | 36 | /** 37 | * Simply get all possible {@link Entity}s from the tx, not worrying whether they are included by 38 | * this policy or not. 39 | * 40 | * @param tx to get entities from. 41 | * @return all entities. 42 | */ 43 | protected abstract Iterable doGetAll(Transaction tx); 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/property/DetachedPropertiesDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.property; 18 | 19 | import com.graphaware.common.description.predicate.Predicate; 20 | 21 | /** 22 | * A {@link PropertiesDescription} that must be detached from the database, i.e. store its own data internally rather 23 | * than referring to an underlying {@link org.neo4j.graphdb.Entity}. It is immutable; once instantiated, 24 | * new instances with different {@link Predicate}s can be constructed using the {@link #with(String, Predicate)} method. 25 | */ 26 | public interface DetachedPropertiesDescription extends PropertiesDescription { 27 | 28 | /** 29 | * Construct a new description from this description by adding/replacing a predicate with a new one. 30 | * 31 | * @param propertyKey key of the property the predicate is for. 32 | * @param predicate the predicate. 33 | * @return a new instance of properties description. 34 | */ 35 | DetachedPropertiesDescription with(String propertyKey, Predicate predicate); 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/property/PropertiesDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.property; 18 | 19 | import com.graphaware.common.description.MutuallyExclusive; 20 | import com.graphaware.common.description.PartiallyComparable; 21 | import com.graphaware.common.description.predicate.Predicate; 22 | 23 | /** 24 | * An immutable description of properties, i.e. a map of predicates (property constraints) keyed by a String property name. 25 | * It is {@link PartiallyComparable} and can judge, whether it is {@link MutuallyExclusive} with another one. 26 | */ 27 | public interface PropertiesDescription extends PartiallyComparable, MutuallyExclusive { 28 | 29 | /** 30 | * Get predicate for a property with the given key. 31 | * 32 | * @param key key. 33 | * @return predicate. Never null. 34 | */ 35 | Predicate get(String key); 36 | 37 | /** 38 | * Get keys of all predicates. 39 | * 40 | * @return all keys. 41 | */ 42 | Iterable getKeys(); 43 | } 44 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/AttachedEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.graphaware.common.expression.EntityExpressions; 20 | import org.neo4j.graphdb.Entity; 21 | 22 | import java.util.Map; 23 | 24 | public abstract class AttachedEntity implements EntityExpressions { 25 | 26 | protected final T entity; 27 | 28 | public AttachedEntity(T entity) { 29 | this.entity = entity; 30 | } 31 | @Override 32 | public Map getProperties() { 33 | return entity.getAllProperties(); 34 | } 35 | 36 | @Override 37 | public boolean equals(Object o) { 38 | if (this == o) return true; 39 | if (o == null || getClass() != o.getClass()) return false; 40 | 41 | AttachedEntity that = (AttachedEntity) o; 42 | 43 | return entity != null ? entity.equals(that.entity) : that.entity == null; 44 | 45 | } 46 | 47 | @Override 48 | public int hashCode() { 49 | return entity != null ? entity.hashCode() : 0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/RelationshipCreated.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.DetachedRelationship; 21 | import com.graphaware.common.representation.GraphDetachedRelationship; 22 | import org.neo4j.graphdb.Relationship; 23 | 24 | /** 25 | * {@link WriteOperation} representing a {@link Relationship} being created. 26 | */ 27 | public class RelationshipCreated extends CreateOrDelete>, Relationship> { 28 | 29 | /** 30 | * Create the operation. 31 | * 32 | * @param createdRelationship representation of the created relationship. Must not be null. 33 | */ 34 | public RelationshipCreated(DetachedRelationship> createdRelationship) { 35 | super(createdRelationship); 36 | } 37 | 38 | @Override 39 | public OperationType getType() { 40 | return OperationType.RELATIONSHIP_CREATED; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/RelationshipDeleted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.DetachedRelationship; 21 | import com.graphaware.common.representation.GraphDetachedRelationship; 22 | import org.neo4j.graphdb.Relationship; 23 | 24 | /** 25 | * {@link WriteOperation} representing a {@link Relationship} being deleted. 26 | */ 27 | public class RelationshipDeleted extends CreateOrDelete>, Relationship> { 28 | 29 | /** 30 | * Create the operation. 31 | * 32 | * @param deletedRelationship representation of the deleted relationship. Must not be null. 33 | */ 34 | public RelationshipDeleted(DetachedRelationship> deletedRelationship) { 35 | super(deletedRelationship); 36 | } 37 | 38 | @Override 39 | public OperationType getType() { 40 | return OperationType.RELATIONSHIP_DELETED; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/GraphDetachedNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.fasterxml.jackson.annotation.JsonIgnore; 20 | import org.neo4j.graphdb.Node; 21 | 22 | import java.util.Map; 23 | 24 | public class GraphDetachedNode extends DetachedNode { 25 | 26 | public GraphDetachedNode() { 27 | } 28 | 29 | public GraphDetachedNode(Node node) { 30 | super(node); 31 | } 32 | 33 | public GraphDetachedNode(Node node, String[] properties) { 34 | super(node, properties); 35 | } 36 | 37 | public GraphDetachedNode(long graphId) { 38 | super(graphId); 39 | } 40 | 41 | public GraphDetachedNode(String[] labels, Map properties) { 42 | super(labels, properties); 43 | } 44 | 45 | public GraphDetachedNode(long graphId, String[] labels, Map properties) { 46 | super(graphId, labels, properties); 47 | } 48 | 49 | @JsonIgnore 50 | @Override 51 | public Long getId() { 52 | return getGraphId(); 53 | } 54 | } 55 | 56 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/input/AllNodesWithLabel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.input; 18 | 19 | import com.graphaware.tx.executor.single.TransactionCallback; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Label; 22 | import org.neo4j.graphdb.Node; 23 | import org.neo4j.graphdb.Transaction; 24 | import org.neo4j.internal.helpers.collection.Iterables; 25 | import org.neo4j.internal.helpers.collection.Iterators; 26 | 27 | import java.util.Iterator; 28 | 29 | /** 30 | * {@link TransactionalInput} returning all nodes with a specific label. 31 | */ 32 | public final class AllNodesWithLabel extends TransactionalInput { 33 | 34 | /** 35 | * Create a new input. 36 | * 37 | * @param database to take all nodes from. 38 | * @param batchSize how many nodes in a batch. 39 | * @param label which all returned nodes have. 40 | */ 41 | public AllNodesWithLabel(GraphDatabaseService database, int batchSize, final Label label) { 42 | super(database, batchSize, tx -> () -> tx.findNodes(label)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/util/Counter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.util; 18 | 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | /** 23 | * Simple counter of objects of type . It's not thread-safe and should not be shared between threads. 24 | */ 25 | public class Counter { 26 | 27 | private final Map counts = new HashMap<>(); 28 | 29 | public void increment(T object) { 30 | increment(object, 1); 31 | } 32 | 33 | public void increment(T object, long delta) { 34 | if (!counts.containsKey(object)) { 35 | counts.put(object, 0L); 36 | } 37 | 38 | counts.put(object, counts.get(object) + delta); 39 | } 40 | 41 | public void decrement(T object) { 42 | decrement(object, 1); 43 | } 44 | 45 | public void decrement(T object, long delta) { 46 | increment(object, -delta); 47 | } 48 | 49 | public void reset() { 50 | counts.clear(); 51 | } 52 | 53 | public long getCount(T object) { 54 | increment(object, 0L); 55 | return counts.get(object); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/config/NullModuleConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.config; 18 | 19 | import com.graphaware.common.policy.inclusion.InclusionPolicies; 20 | import com.graphaware.runtime.module.Module; 21 | import com.graphaware.runtime.policy.InclusionPoliciesFactory; 22 | 23 | /** 24 | * {@link ModuleConfiguration} for {@link Module}s with no configuration. Singleton. 25 | */ 26 | public final class NullModuleConfiguration implements ModuleConfiguration { 27 | 28 | private static final ModuleConfiguration INSTANCE = new NullModuleConfiguration(); 29 | private final InclusionPolicies inclusionPolicies; 30 | 31 | /** 32 | * Get instance of this singleton configuration. 33 | * 34 | * @return instance. 35 | */ 36 | public static ModuleConfiguration getInstance() { 37 | return INSTANCE; 38 | } 39 | 40 | private NullModuleConfiguration() { 41 | inclusionPolicies = InclusionPoliciesFactory.allBusiness(); 42 | } 43 | 44 | @Override 45 | public InclusionPolicies getInclusionPolicies() { 46 | return inclusionPolicies; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/src/test/resources/statements.cyp: -------------------------------------------------------------------------------- 1 | MERGE (n1:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0' }) 2 | SET n1.name = 'Isabell McGlynn'; 3 | MERGE (n2:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a' }) 4 | SET n2.name = 'Kelton Kuhn'; 5 | MERGE (n3:Person {neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b' }) 6 | SET n3.name = 'Chesley Feil'; 7 | MERGE (n4:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684' }) 8 | SET n4.name = 'Adrain Daugherty'; 9 | MERGE (n5:Person {neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455' }) 10 | SET n5.name = 'Kyleigh Stehr'; 11 | MATCH (s1:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}), (e1:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 12 | MERGE (s1)-[edge1:KNOWS]->(e1) 13 | ; 14 | MATCH (s2:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}), (e2:Person { neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b'}) 15 | MERGE (s2)-[edge2:KNOWS]->(e2) 16 | ; 17 | MATCH (s3:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}), (e3:Person { neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}) 18 | MERGE (s3)-[edge3:KNOWS]->(e3) 19 | ; 20 | MATCH (s4:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}), (e4:Person { neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}) 21 | MERGE (s4)-[edge4:KNOWS]->(e4) 22 | ; 23 | MATCH (s5:Person {neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b'}), (e5:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 24 | MERGE (s5)-[edge5:KNOWS]->(e5) 25 | ; 26 | MATCH (s6:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684'}), (e6:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 27 | MERGE (s6)-[edge6:KNOWS]->(e6) 28 | ; 29 | MATCH (s7:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684'}), (e7:Person { neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}) 30 | MERGE (s7)-[edge7:KNOWS]->(e7) 31 | ; 32 | MATCH (n1:Person) REMOVE n1.neogen_id; 33 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/transform/IdTransformer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.transform; 18 | 19 | import com.graphaware.common.representation.DetachedEntity; 20 | import org.neo4j.graphdb.Entity; 21 | 22 | /** 23 | * A transformer of custom IDs to and from internal Neo4j {@link Entity} IDs. 24 | * 25 | * @param custom ID type. 26 | * @param entity type. 27 | */ 28 | public interface IdTransformer { 29 | 30 | /** 31 | * Transform a custom ID to internal Neo4j ID. 32 | * 33 | * @param id to transform. Can be null, which represents a new entity not yet persisted to the database. 34 | * @return internal Neo4j ID. {@link DetachedEntity#NEW} should be returned in case the id parameter is null. 35 | */ 36 | long toGraphId(ID id); 37 | 38 | /** 39 | * Transform an internal Neo4j node ID of a {@link Entity} to a custom ID. 40 | * 41 | * @param entity to take the ID to transform from. Must not be null. 42 | * @return transformed custom ID. Never null. 43 | */ 44 | ID fromEntity(E entity); 45 | } 46 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/single/RethrowException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.single; 18 | 19 | import org.neo4j.logging.Log; 20 | import com.graphaware.common.log.LoggerFactory; 21 | 22 | /** 23 | * {@link ExceptionHandlingStrategy} that logs the exception and re-throws it. 24 | *

25 | * Note that this is a singleton. 26 | */ 27 | public final class RethrowException implements ExceptionHandlingStrategy { 28 | private static final Log LOG = LoggerFactory.getLogger(RethrowException.class); 29 | 30 | private static final RethrowException INSTANCE = new RethrowException(); 31 | 32 | /** 33 | * Get an instance of this strategy. 34 | * 35 | * @return singleton instance. 36 | */ 37 | public static RethrowException getInstance() { 38 | return INSTANCE; 39 | } 40 | 41 | @Override 42 | public void handleException(RuntimeException e) { 43 | LOG.warn("An exception occurred while executing transaction", e); 44 | throw e; 45 | } 46 | 47 | /** 48 | * Private constructor to enforce singleton. 49 | */ 50 | private RethrowException() { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/spel/SpelRelationshipPropertyInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion.spel; 18 | 19 | import com.graphaware.common.policy.inclusion.RelationshipPropertyInclusionPolicy; 20 | import com.graphaware.common.representation.AttachedRelationship; 21 | import com.graphaware.common.representation.AttachedRelationshipProperty; 22 | import com.graphaware.common.representation.RelationshipProperty; 23 | import org.neo4j.graphdb.Relationship; 24 | 25 | /** 26 | * {@link RelationshipPropertyInclusionPolicy} based on a SPEL expression. The expression can use methods defined in 27 | * {@link RelationshipProperty}. 28 | */ 29 | public class SpelRelationshipPropertyInclusionPolicy extends SpelInclusionPolicy implements RelationshipPropertyInclusionPolicy { 30 | 31 | public SpelRelationshipPropertyInclusionPolicy(String expression) { 32 | super(expression); 33 | } 34 | 35 | @Override 36 | public boolean include(String key, Relationship relationship) { 37 | return (Boolean) exp.getValue(new AttachedRelationshipProperty(key, new AttachedRelationship(relationship))); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/change-logger/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 4.0.0 19 | 20 | com.graphaware.neo4j.example 21 | change-logger 22 | 4.2.0.59-SNAPSHOT 23 | jar 24 | 25 | 26 | com.graphaware.neo4j 27 | module-parent 28 | 4.2.0.59-SNAPSHOT 29 | ../../module-parent/pom.xml 30 | 31 | 32 | GraphAware Change Logger 33 | Example of a Neo4j Transaction Event Handler with GraphAware Improved Transaction API 34 | http://graphaware.com 35 | 36 | 37 | 38 | 39 | com.graphaware.neo4j 40 | tx-api 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/json/StringIdJsonNode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.json; 18 | 19 | import com.graphaware.common.transform.NodeIdTransformer; 20 | import org.neo4j.graphdb.GraphDatabaseService; 21 | import org.neo4j.graphdb.Node; 22 | import org.neo4j.graphdb.Transaction; 23 | 24 | import java.util.Map; 25 | 26 | /** 27 | * {@link JsonNode} with {@link String} custom ID. 28 | */ 29 | public class StringIdJsonNode extends JsonNode { 30 | 31 | public StringIdJsonNode() { 32 | } 33 | 34 | public StringIdJsonNode(Node node, NodeIdTransformer transformer) { 35 | super(node, transformer); 36 | } 37 | 38 | public StringIdJsonNode(Node node, String[] properties, NodeIdTransformer transformer) { 39 | super(node, properties, transformer); 40 | } 41 | 42 | public StringIdJsonNode(String id, String[] labels, Map properties) { 43 | super(id, labels, properties); 44 | } 45 | 46 | @Override 47 | public Node produceEntity(Transaction tx) { 48 | throw new UnsupportedOperationException("Please use produceEntity(Transaction tx, NodeIdTransformer transformer)"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/util/BlockingArrayBlockingQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.util; 18 | 19 | import java.util.concurrent.ArrayBlockingQueue; 20 | import java.util.concurrent.TimeUnit; 21 | 22 | /** 23 | * {@link ArrayBlockingQueue} that blocks for a specified amount of time on {@link java.util.Queue#offer(Object)}, throwing 24 | * a {@link RuntimeException} upon timeout. The timeout is 30 minutes by default and can be changed by overriding 25 | * {@link #timeoutMinutes()}. 26 | * 27 | * @param 28 | */ 29 | public class BlockingArrayBlockingQueue extends ArrayBlockingQueue { 30 | 31 | public BlockingArrayBlockingQueue(int capacity) { 32 | super(capacity); 33 | } 34 | 35 | @Override 36 | public boolean offer(E e) { 37 | try { 38 | return offer(e, timeoutMinutes(), TimeUnit.MINUTES); 39 | } catch (InterruptedException ex) { 40 | throw new RuntimeException(ex); 41 | } 42 | } 43 | 44 | /** 45 | * @return number of minutes to block on offer, before throwing a {@link RuntimeException}. 46 | */ 47 | protected int timeoutMinutes() { 48 | return 30; 49 | } 50 | } 51 | 52 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/description/relationship/DetachedRelationshipDescription.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.description.relationship; 18 | 19 | import com.graphaware.common.description.predicate.Predicate; 20 | import com.graphaware.common.description.property.PropertiesDescription; 21 | 22 | /** 23 | * A {@link RelationshipDescription} that must be detached from the database, i.e. store its own data internally rather 24 | * than referring to an underlying {@link org.neo4j.graphdb.Relationship}. It is immutable; once instantiated, 25 | * new instances with different {@link PropertiesDescription}s can be constructed using the {@link #with(String, Predicate)} method. 26 | */ 27 | public interface DetachedRelationshipDescription extends RelationshipDescription { 28 | 29 | /** 30 | * Construct a new description from this description by adding/replacing a properties predicate with a new one. 31 | * 32 | * @param propertyKey key of the property the predicate is for. 33 | * @param predicate the predicate. 34 | * @return a new instance of relationship description. 35 | */ 36 | DetachedRelationshipDescription with(String propertyKey, Predicate predicate); 37 | } 38 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/module/thirdparty/DefaultThirdPartyIntegrationModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.module.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedNode; 20 | import com.graphaware.common.representation.DetachedRelationship; 21 | import com.graphaware.common.representation.GraphDetachedNode; 22 | import com.graphaware.common.representation.GraphDetachedRelationship; 23 | import com.graphaware.writer.thirdparty.ThirdPartyWriter; 24 | import org.neo4j.graphdb.Node; 25 | import org.neo4j.graphdb.Relationship; 26 | 27 | public class DefaultThirdPartyIntegrationModule extends WriterBasedThirdPartyIntegrationModule { 28 | 29 | public DefaultThirdPartyIntegrationModule(String moduleId, ThirdPartyWriter writer) { 30 | super(moduleId, writer); 31 | } 32 | 33 | @Override 34 | protected DetachedRelationship> relationshipRepresentation(Relationship relationship) { 35 | return new GraphDetachedRelationship(relationship); 36 | } 37 | 38 | @Override 39 | protected DetachedNode nodeRepresentation(Node node) { 40 | return new GraphDetachedNode(node); 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /tests/src/test/resources/graphgen.cyp: -------------------------------------------------------------------------------- 1 | CREATE CONSTRAINT ON (person:Person) ASSERT person.neogen_id IS UNIQUE; 2 | MERGE (n1:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0' }) 3 | SET n1.name = 'Isabell McGlynn'; 4 | MERGE (n2:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a' }) 5 | SET n2.name = 'Kelton Kuhn'; 6 | MERGE (n3:Person {neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b' }) 7 | SET n3.name = 'Chesley Feil'; 8 | MERGE (n4:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684' }) 9 | SET n4.name = 'Adrain Daugherty'; 10 | MERGE (n5:Person {neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455' }) 11 | SET n5.name = 'Kyleigh Stehr'; 12 | MATCH (s1:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}), (e1:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 13 | MERGE (s1)-[edge1:KNOWS]->(e1) 14 | ; 15 | MATCH (s2:Person {neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}), (e2:Person { neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b'}) 16 | MERGE (s2)-[edge2:KNOWS]->(e2) 17 | ; 18 | MATCH (s3:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}), (e3:Person { neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}) 19 | MERGE (s3)-[edge3:KNOWS]->(e3) 20 | ; 21 | MATCH (s4:Person {neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}), (e4:Person { neogen_id: '23b01990b61ae118247ea9a6b13b8280e9eb32b0'}) 22 | MERGE (s4)-[edge4:KNOWS]->(e4) 23 | ; 24 | MATCH (s5:Person {neogen_id: '1a7de07ed950b92263b1c763559d7fa65097763b'}), (e5:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 25 | MERGE (s5)-[edge5:KNOWS]->(e5) 26 | ; 27 | MATCH (s6:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684'}), (e6:Person { neogen_id: '001ffaa40b9998c965fdcc02f91e214f0a5a3455'}) 28 | MERGE (s6)-[edge6:KNOWS]->(e6) 29 | ; 30 | MATCH (s7:Person {neogen_id: '6059f852ea954e29e5e24493df2cb85291b13684'}), (e7:Person { neogen_id: '3d85518e3182a82412cdc2982a2b12b8e55d341a'}) 31 | MERGE (s7)-[edge7:KNOWS]->(e7) 32 | ; 33 | MATCH (n1:Person) REMOVE n1.neogen_id; 34 | -------------------------------------------------------------------------------- /tx-executor/src/main/java/com/graphaware/tx/executor/batch/NoInputBatchTransactionExecutor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.tx.executor.batch; 18 | 19 | import com.graphaware.tx.executor.NullItem; 20 | import com.graphaware.tx.executor.input.NoInput; 21 | import org.neo4j.graphdb.GraphDatabaseService; 22 | 23 | /** 24 | * A {@link BatchTransactionExecutor} that executes a specified number of {@link UnitOfWork} in batches. 25 | * These units need no input. 26 | */ 27 | public class NoInputBatchTransactionExecutor extends IterableInputBatchTransactionExecutor implements BatchTransactionExecutor { 28 | 29 | /** 30 | * Construct a new batch executor. 31 | * 32 | * @param database against which to execute batched queries. 33 | * @param batchSize how many {@link UnitOfWork} are in a single batch. 34 | * @param noSteps how many {@link UnitOfWork} should be executed in total. 35 | * @param unitOfWork a unit of work definition. Must be thread-safe. 36 | */ 37 | public NoInputBatchTransactionExecutor(GraphDatabaseService database, int batchSize, int noSteps, UnitOfWork unitOfWork) { 38 | super(database, batchSize, new NoInput(noSteps), unitOfWork); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/friendship-strength-counter/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 4.0.0 19 | 20 | com.graphaware.neo4j.example 21 | friendship-strength-counter 22 | 4.2.0.59-SNAPSHOT 23 | jar 24 | 25 | 26 | com.graphaware.neo4j 27 | module-parent 28 | 4.2.0.59-SNAPSHOT 29 | ../../module-parent/pom.xml 30 | 31 | 32 | GraphAware Friendship Strength Counter 33 | Example of a Neo4j Transaction Event Handler with GraphAware Improved Transaction API 34 | http://graphaware.com 35 | 36 | 37 | 38 | 39 | com.graphaware.neo4j 40 | tx-api 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/policy/inclusion/RelationshipInclusionPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.policy.inclusion; 18 | 19 | 20 | import org.neo4j.graphdb.Node; 21 | import org.neo4j.graphdb.Relationship; 22 | 23 | /** 24 | * {@link EntityInclusionPolicy} for {@link Relationship}s. 25 | */ 26 | public interface RelationshipInclusionPolicy extends EntityInclusionPolicy { 27 | 28 | /** 29 | * Include the given relationships from the given node's point of view? 30 | * 31 | * @param relationship to make a decision on. 32 | * @param pointOfView node looking at the relationship. Must be one of the relationship's nodes. 33 | * @return true to include, false to exclude. 34 | */ 35 | boolean include(Relationship relationship, Node pointOfView); 36 | 37 | /** 38 | * Adapter for implementations that don't care about which node is looking at the relationship. 39 | */ 40 | abstract class Adapter extends BaseRelationshipInclusionPolicy implements RelationshipInclusionPolicy { 41 | 42 | @Override 43 | public boolean include(Relationship relationship, Node pointOfView) { 44 | return include(relationship); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tx-api/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 4.0.0 19 | 20 | 21 | com.graphaware.neo4j 22 | graphaware-parent 23 | 4.2.0.59-SNAPSHOT 24 | 25 | 26 | tx-api 27 | 28 | GraphAware Transaction API 29 | Improved Transaction API with Graph Snapshotting 30 | http://graphaware.com 31 | 32 | 33 | 34 | com.graphaware.neo4j 35 | common 36 | 37 | 38 | com.graphaware.neo4j 39 | tx-executor 40 | 41 | 42 | com.graphaware.neo4j 43 | tests 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /writer/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 4.0.0 19 | 20 | 21 | com.graphaware.neo4j 22 | graphaware-parent 23 | 4.2.0.59-SNAPSHOT 24 | 25 | 26 | writer 27 | 28 | GraphAware Database Writer 29 | Alternative Database Writing Strategies 30 | http://graphaware.com 31 | 32 | 33 | 34 | 35 | com.graphaware.neo4j 36 | tx-executor 37 | 38 | 39 | 40 | com.graphaware.neo4j 41 | tests 42 | 43 | 44 | 45 | com.google.guava 46 | guava 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /writer/src/main/java/com/graphaware/writer/thirdparty/Update.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.writer.thirdparty; 18 | 19 | import com.graphaware.common.representation.DetachedEntity; 20 | import com.graphaware.common.util.Change; 21 | import org.neo4j.graphdb.Entity; 22 | 23 | import static org.springframework.util.Assert.notNull; 24 | 25 | /** 26 | * {@link BaseWriteOperation} representing an update operation. 27 | * 28 | * @param type of the details object. 29 | * @param type of the {@link Entity} that the operation was performed on. 30 | */ 31 | public abstract class Update, T extends Entity> extends BaseWriteOperation> { 32 | 33 | /** 34 | * Create the operation. 35 | * 36 | * @param previous representation of the previous state of the updated {@link Entity}. Must not be null. 37 | * @param current representation of the current state of the updated {@link Entity}. Must not be null. 38 | */ 39 | protected Update(R previous, R current) { 40 | super(new Change<>(previous, current)); 41 | 42 | notNull(previous, "Previous entity must not be null"); 43 | notNull(current, "Current entity must not be null"); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tx-executor/pom.xml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 4.0.0 19 | 20 | 21 | com.graphaware.neo4j 22 | graphaware-parent 23 | 4.2.0.59-SNAPSHOT 24 | 25 | 26 | tx-executor 27 | 28 | GraphAware Transaction Executor 29 | Single and Batch Transaction Executor 30 | http://graphaware.com 31 | 32 | 33 | 34 | com.graphaware.neo4j 35 | common 36 | 37 | 38 | 39 | com.graphaware.neo4j 40 | tests 41 | 42 | 43 | 44 | com.google.guava 45 | guava 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /common/src/main/java/com/graphaware/common/representation/AttachedRelationship.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.common.representation; 18 | 19 | import com.graphaware.common.expression.AttachedRelationshipExpressions; 20 | import org.neo4j.graphdb.Node; 21 | import org.neo4j.graphdb.Relationship; 22 | 23 | public class AttachedRelationship extends AttachedEntity implements AttachedRelationshipExpressions { 24 | 25 | private final Node pointOfView; 26 | 27 | public AttachedRelationship(Relationship entity) { 28 | this(entity, null); 29 | } 30 | 31 | public AttachedRelationship(Relationship entity, Node pointOfView) { 32 | super(entity); 33 | this.pointOfView = pointOfView; 34 | } 35 | 36 | @Override 37 | public String getType() { 38 | return entity.getType().name(); 39 | } 40 | 41 | @Override 42 | public AttachedNode getStartNode() { 43 | return new AttachedNode(entity.getStartNode()); 44 | } 45 | 46 | @Override 47 | public AttachedNode getEndNode() { 48 | return new AttachedNode(entity.getEndNode()); 49 | } 50 | 51 | @Override 52 | public AttachedNode pointOfView() { 53 | return new AttachedNode(pointOfView); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /runtime/src/main/java/com/graphaware/runtime/policy/all/IncludeAllBusinessNodeProperties.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2020 GraphAware 3 | * 4 | * This file is part of the GraphAware Framework. 5 | * 6 | * GraphAware Framework is free software: you can redistribute it and/or modify it under 7 | * the terms of the GNU General Public License as published by the Free Software Foundation, either 8 | * version 3 of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 11 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 | * See the GNU General Public License for more details. You should have received a copy of 13 | * the GNU General Public License along with this program. If not, see 14 | * . 15 | */ 16 | 17 | package com.graphaware.runtime.policy.all; 18 | 19 | import com.graphaware.common.policy.inclusion.NodePropertyInclusionPolicy; 20 | import com.graphaware.common.policy.inclusion.PropertyInclusionPolicy; 21 | import com.graphaware.runtime.GraphAwareRuntime; 22 | import com.graphaware.runtime.module.Module; 23 | import org.neo4j.graphdb.Node; 24 | 25 | /** 26 | * {@link Node} {@link PropertyInclusionPolicy} that includes arbitrary business / application level 27 | * properties (up to subclasses to decide which ones), but excludes any 28 | * {@link com.graphaware.runtime.GraphAwareRuntime}/{@link Module} internal properties. 29 | */ 30 | public final class IncludeAllBusinessNodeProperties implements NodePropertyInclusionPolicy { 31 | 32 | private static final NodePropertyInclusionPolicy INSTANCE = new IncludeAllBusinessNodeProperties(); 33 | 34 | public static NodePropertyInclusionPolicy getInstance() { 35 | return INSTANCE; 36 | } 37 | 38 | private IncludeAllBusinessNodeProperties() { 39 | } 40 | 41 | @Override 42 | public boolean include(String key, Node node) { 43 | return !key.startsWith(GraphAwareRuntime.GA_PREFIX); 44 | } 45 | } 46 | --------------------------------------------------------------------------------