From 775e76368b8826ec74b17196b5079c7a06a035ed Mon Sep 17 00:00:00 2001 From: 20001LastOrder Date: Mon, 24 Jun 2019 10:19:53 -0400 Subject: add sample domain for measuring realistic metrics --- .../SocialNetwork_plugin/.classpath | 10 + .../SocialNetwork_plugin/.project | 40 +++ .../.settings/org.eclipse.jdt.core.prefs | 7 + .../Metrics-Calculation/SocialNetwork_plugin/1.csv | 1 + .../SocialNetwork_plugin/META-INF/MANIFEST.MF | 30 +++ .../SocialNetworkGeneration.vsconfig | 24 ++ .../SocialNetwork_plugin/bin/.gitignore | 6 + .../SocialNetwork_plugin/build.properties | 9 + .../data/Yakinduum/mpc_rep.csv | 9 + .../SocialNetwork_plugin/data/Yakinduum/na_rep.csv | 9 + .../data/Yakinduum/out_d_rep.csv | 9 + .../SocialNetwork_plugin/debug/.gitignore | 4 + .../encore_gen/socialnetwork/Person.java | 62 +++++ .../encore_gen/socialnetwork/SocialNetwork.java | 62 +++++ .../socialnetwork/SocialnetworkFactory.java | 51 ++++ .../socialnetwork/SocialnetworkPackage.java | 293 ++++++++++++++++++++ .../encore_gen/socialnetwork/impl/PersonImpl.java | 208 ++++++++++++++ .../socialnetwork/impl/SocialNetworkImpl.java | 228 ++++++++++++++++ .../impl/SocialnetworkFactoryImpl.java | 111 ++++++++ .../impl/SocialnetworkPackageImpl.java | 267 ++++++++++++++++++ .../util/SocialnetworkAdapterFactory.java | 138 ++++++++++ .../socialnetwork/util/SocialnetworkSwitch.java | 134 +++++++++ .../SocialNetwork_plugin/generator.vqgen | 1 + .../SocialNetwork_plugin/inputs/.gitignore | 4 + .../SocialNetwork_plugin/model/socialnetwork.aird | 183 +++++++++++++ .../SocialNetwork_plugin/model/socialnetwork.ecore | 17 ++ .../model/socialnetwork.genmodel | 21 ++ .../model/statistics/200_nodes.jpg | Bin 0 -> 49128 bytes .../model/statistics/220_nodes.jpg | Bin 0 -> 51088 bytes .../model/statistics/260_nodes.jpg | Bin 0 -> 51426 bytes .../model/statistics/280_nodes.jpg | Bin 0 -> 50852 bytes .../model/statistics/output.txt | 300 +++++++++++++++++++++ .../model/statistics/plot_distribution.m | 11 + .../SocialNetwork_plugin/output.txt | 9 + .../SocialNetwork_plugin/output/.gitignore | 4 + .../SocialNetwork_plugin/plugin.properties | 4 + .../SocialNetwork_plugin/plugin.xml | 15 ++ .../ca/mcgill/ecse/socialnetwork/plugin/.gitignore | 10 + .../mcgill/ecse/socialnetwork/plugin/Queries.vql | 54 ++++ .../ca/mcgill/ecse/socialnetwork/runner/Main.java | 128 +++++++++ .../ecse/socialnetwork/runner/Persisitence.java | 63 +++++ .../ecse/socialnetwork/runner/RunnerTests.java | 18 ++ .../socialnetwork/runner/SocialNetworkModel.java | 62 +++++ .../ecse/socialnetwork/runner/YakinduumModel.java | 52 ++++ .../yakinduGeneration.vsconfig | 23 ++ .../SocialNetwork_plugin/yakinduum/1.xmi | 130 +++++++++ .../SocialNetwork_plugin/yakinduum/info.csv | 2 + 47 files changed, 2823 insertions(+) create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/.classpath create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/.project create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/.settings/org.eclipse.jdt.core.prefs create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/1.csv create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/META-INF/MANIFEST.MF create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/SocialNetworkGeneration.vsconfig create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/bin/.gitignore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/build.properties create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/mpc_rep.csv create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/na_rep.csv create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/out_d_rep.csv create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/debug/.gitignore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/Person.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialNetwork.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkFactory.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkPackage.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/PersonImpl.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialNetworkImpl.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkFactoryImpl.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkPackageImpl.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkAdapterFactory.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkSwitch.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/generator.vqgen create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/inputs/.gitignore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.aird create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.ecore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.genmodel create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/200_nodes.jpg create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/220_nodes.jpg create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/260_nodes.jpg create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/280_nodes.jpg create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/output.txt create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/plot_distribution.m create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/output.txt create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/output/.gitignore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.properties create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.xml create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src-gen/ca/mcgill/ecse/socialnetwork/plugin/.gitignore create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/plugin/Queries.vql create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Persisitence.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/RunnerTests.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/SocialNetworkModel.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/YakinduumModel.java create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduGeneration.vsconfig create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/1.xmi create mode 100644 Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/info.csv diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/.classpath b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.classpath new file mode 100644 index 00000000..58c238b9 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/.project b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.project new file mode 100644 index 00000000..decac49c --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.project @@ -0,0 +1,40 @@ + + + SocialNetwork_plugin + + + + + + org.eclipse.viatra.query.tooling.ui.projectbuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + org.eclipse.viatra.query.projectnature + org.eclipse.xtext.ui.shared.xtextNature + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/.settings/org.eclipse.jdt.core.prefs b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..0c68a61d --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/1.csv b/Metrics/Metrics-Calculation/SocialNetwork_plugin/1.csv new file mode 100644 index 00000000..b7f73ed2 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/1.csv @@ -0,0 +1 @@ +Time,0 : 0.0 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/META-INF/MANIFEST.MF b/Metrics/Metrics-Calculation/SocialNetwork_plugin/META-INF/MANIFEST.MF new file mode 100644 index 00000000..b7ec683a --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/META-INF/MANIFEST.MF @@ -0,0 +1,30 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: SocialNetwork_plugin;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Export-Package: ca.mcgill.ecse.socialnetwork.plugin, + socialnetwork, + socialnetwork.impl, + socialnetwork.util +Require-Bundle: org.eclipse.viatra.query.runtime.rete, + org.eclipse.viatra.query.runtime.localsearch, + org.eclipse.xtext.xbase.lib, + org.eclipse.viatra.query.runtime, + org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.ecore.xmi;bundle-version="2.15.0", + hu.bme.mit.inf.dslreasoner.application;bundle-version="1.0.0", + org.junit;bundle-version="4.12.0", + org.eclipse.collections;bundle-version="9.2.0", + hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph;bundle-version="1.0.0", + ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator;bundle-version="1.0.0", + hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.validation;bundle-version="0.0.1" +Import-Package: org.apache.log4j, + org.junit;version="4.12.0" +Automatic-Module-Name: SocialNetwork_plugin +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/SocialNetworkGeneration.vsconfig b/Metrics/Metrics-Calculation/SocialNetwork_plugin/SocialNetworkGeneration.vsconfig new file mode 100644 index 00000000..e051c659 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/SocialNetworkGeneration.vsconfig @@ -0,0 +1,24 @@ +import epackage "model/socialnetwork.ecore" +import viatra "src/ca/mcgill/ecse/socialnetwork/plugin/Queries.vql" + +generate { + metamodel = { package socialnetwork } + //constraints = { package ca.mcgill.ecse.socialnetwork.plugin } + partial-model = { "inputs/280nodes.xmi"} + + solver = ViatraSolver + + scope = { + #node = 301 + } + + number = 1 + runs = 1 + config = { + log-level = normal + } + + debug = "output/debug" + output = "output" + log = "output/log.txt" +} \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/bin/.gitignore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/bin/.gitignore new file mode 100644 index 00000000..67ee5625 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/bin/.gitignore @@ -0,0 +1,6 @@ +/ca/ +/socialnetwork.aird +/socialnetwork.ecore +/socialnetwork.genmodel +/socialnetwork/ +/statistics/ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/build.properties b/Metrics/Metrics-Calculation/SocialNetwork_plugin/build.properties new file mode 100644 index 00000000..63ef0274 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/build.properties @@ -0,0 +1,9 @@ +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = encore_gen/,\ + src-gen/ +output.. = bin/ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/mpc_rep.csv b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/mpc_rep.csv new file mode 100644 index 00000000..fc39ac54 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/mpc_rep.csv @@ -0,0 +1,9 @@ +Meta Mode,yakindumm +Number of Edge types,6 +Number Of Nodes,67 +OutDegreeValue,1,2,3,4,6,8,9 +OutDegreeCount,4,45,9,1,1,2,5 +NAValue,1,2,3,4,5,6 +NACount,1,3,4,42,15,2 +MPCValue,0.00000,0.21600,0.45000,0.76800,0.80000,0.89751,0.90000,0.91349,0.92410,0.93061,0.93728,0.96000,0.97500,1.00000 +MPCCount,1,2,1,1,3,1,42,2,2,7,1,2,1,1 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/na_rep.csv b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/na_rep.csv new file mode 100644 index 00000000..43d411e4 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/na_rep.csv @@ -0,0 +1,9 @@ +Meta Mode,yakindumm +Number of Edge types,6 +Number Of Nodes,98 +OutDegreeValue,1,2,3,4,5,6,10,15 +OutDegreeCount,7,61,17,2,3,2,5,1 +NAValue,1,2,3,4,5,6 +NACount,1,4,6,62,23,2 +MPCValue,0.00000,0.14062,0.19835,0.38400,0.45000,0.80000,0.86667,0.90000,0.90888,0.91429,0.93061,0.93223,0.94815,0.98400,1.00000 +MPCCount,1,1,1,1,1,6,1,61,2,4,14,2,1,1,1 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/out_d_rep.csv b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/out_d_rep.csv new file mode 100644 index 00000000..17965018 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/data/Yakinduum/out_d_rep.csv @@ -0,0 +1,9 @@ +Meta Mode,yakindumm +Number of Edge types,6 +Number Of Nodes,88 +OutDegreeValue,1,2,3,4,5,6,8,10,11,13 +OutDegreeCount,6,57,12,3,1,2,2,3,1,1 +NAValue,1,2,3,4,5,6 +NACount,1,3,6,56,20,2 +MPCValue,0.00000,0.15918,0.18333,0.38400,0.76800,0.80000,0.88889,0.90000,0.90888,0.91349,0.91429,0.93061,0.93223,0.93728,1.00000 +MPCCount,1,1,1,1,1,5,2,56,1,2,3,10,1,1,2 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/debug/.gitignore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/debug/.gitignore new file mode 100644 index 00000000..17126b28 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/debug/.gitignore @@ -0,0 +1,4 @@ +# ignore everything in this folder except for this folder it self + +* +!.gitignore \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/Person.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/Person.java new file mode 100644 index 00000000..b1e0a041 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/Person.java @@ -0,0 +1,62 @@ +/** + */ +package socialnetwork; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Person'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see socialnetwork.SocialnetworkPackage#getPerson() + * @model + * @generated + */ +public interface Person extends EObject { + /** + * Returns the value of the 'Friends' reference list. + * The list contents are of type {@link socialnetwork.Person}. + * + * + * @return the value of the 'Friends' reference list. + * @see socialnetwork.SocialnetworkPackage#getPerson_Friends() + * @model + * @generated + */ + EList getFriends(); + + /** + * Returns the value of the 'Name' attribute. + * The default value is "Name". + * + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see socialnetwork.SocialnetworkPackage#getPerson_Name() + * @model default="Name" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link socialnetwork.Person#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + +} // Person diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialNetwork.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialNetwork.java new file mode 100644 index 00000000..4653f6dd --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialNetwork.java @@ -0,0 +1,62 @@ +/** + */ +package socialnetwork; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Social Network'. + * + * + *

+ * The following features are supported: + *

+ * + * + * @see socialnetwork.SocialnetworkPackage#getSocialNetwork() + * @model + * @generated + */ +public interface SocialNetwork extends EObject { + /** + * Returns the value of the 'Name' attribute. + * The default value is "SocialNetwork". + * + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see socialnetwork.SocialnetworkPackage#getSocialNetwork_Name() + * @model default="SocialNetwork" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link socialnetwork.SocialNetwork#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Persons' containment reference list. + * The list contents are of type {@link socialnetwork.Person}. + * + * + * @return the value of the 'Persons' containment reference list. + * @see socialnetwork.SocialnetworkPackage#getSocialNetwork_Persons() + * @model containment="true" + * @generated + */ + EList getPersons(); + +} // SocialNetwork diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkFactory.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkFactory.java new file mode 100644 index 00000000..cf7a4250 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkFactory.java @@ -0,0 +1,51 @@ +/** + */ +package socialnetwork; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see socialnetwork.SocialnetworkPackage + * @generated + */ +public interface SocialnetworkFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SocialnetworkFactory eINSTANCE = socialnetwork.impl.SocialnetworkFactoryImpl.init(); + + /** + * Returns a new object of class 'Social Network'. + * + * + * @return a new object of class 'Social Network'. + * @generated + */ + SocialNetwork createSocialNetwork(); + + /** + * Returns a new object of class 'Person'. + * + * + * @return a new object of class 'Person'. + * @generated + */ + Person createPerson(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + SocialnetworkPackage getSocialnetworkPackage(); + +} //SocialnetworkFactory diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkPackage.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkPackage.java new file mode 100644 index 00000000..f215f469 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/SocialnetworkPackage.java @@ -0,0 +1,293 @@ +/** + */ +package socialnetwork; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see socialnetwork.SocialnetworkFactory + * @model kind="package" + * annotation="http://www.eclipse.org/emf/2002/Ecore" + * @generated + */ +public interface SocialnetworkPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "socialnetwork"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://ecse.mcgill.ca/socialnetwork"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "socialnetwork"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + SocialnetworkPackage eINSTANCE = socialnetwork.impl.SocialnetworkPackageImpl.init(); + + /** + * The meta object id for the '{@link socialnetwork.impl.SocialNetworkImpl Social Network}' class. + * + * + * @see socialnetwork.impl.SocialNetworkImpl + * @see socialnetwork.impl.SocialnetworkPackageImpl#getSocialNetwork() + * @generated + */ + int SOCIAL_NETWORK = 0; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int SOCIAL_NETWORK__NAME = 0; + + /** + * The feature id for the 'Persons' containment reference list. + * + * + * @generated + * @ordered + */ + int SOCIAL_NETWORK__PERSONS = 1; + + /** + * The number of structural features of the 'Social Network' class. + * + * + * @generated + * @ordered + */ + int SOCIAL_NETWORK_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Social Network' class. + * + * + * @generated + * @ordered + */ + int SOCIAL_NETWORK_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link socialnetwork.impl.PersonImpl Person}' class. + * + * + * @see socialnetwork.impl.PersonImpl + * @see socialnetwork.impl.SocialnetworkPackageImpl#getPerson() + * @generated + */ + int PERSON = 1; + + /** + * The feature id for the 'Friends' reference list. + * + * + * @generated + * @ordered + */ + int PERSON__FRIENDS = 0; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int PERSON__NAME = 1; + + /** + * The number of structural features of the 'Person' class. + * + * + * @generated + * @ordered + */ + int PERSON_FEATURE_COUNT = 2; + + /** + * The number of operations of the 'Person' class. + * + * + * @generated + * @ordered + */ + int PERSON_OPERATION_COUNT = 0; + + /** + * Returns the meta object for class '{@link socialnetwork.SocialNetwork Social Network}'. + * + * + * @return the meta object for class 'Social Network'. + * @see socialnetwork.SocialNetwork + * @generated + */ + EClass getSocialNetwork(); + + /** + * Returns the meta object for the attribute '{@link socialnetwork.SocialNetwork#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see socialnetwork.SocialNetwork#getName() + * @see #getSocialNetwork() + * @generated + */ + EAttribute getSocialNetwork_Name(); + + /** + * Returns the meta object for the containment reference list '{@link socialnetwork.SocialNetwork#getPersons Persons}'. + * + * + * @return the meta object for the containment reference list 'Persons'. + * @see socialnetwork.SocialNetwork#getPersons() + * @see #getSocialNetwork() + * @generated + */ + EReference getSocialNetwork_Persons(); + + /** + * Returns the meta object for class '{@link socialnetwork.Person Person}'. + * + * + * @return the meta object for class 'Person'. + * @see socialnetwork.Person + * @generated + */ + EClass getPerson(); + + /** + * Returns the meta object for the reference list '{@link socialnetwork.Person#getFriends Friends}'. + * + * + * @return the meta object for the reference list 'Friends'. + * @see socialnetwork.Person#getFriends() + * @see #getPerson() + * @generated + */ + EReference getPerson_Friends(); + + /** + * Returns the meta object for the attribute '{@link socialnetwork.Person#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see socialnetwork.Person#getName() + * @see #getPerson() + * @generated + */ + EAttribute getPerson_Name(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + SocialnetworkFactory getSocialnetworkFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each operation of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link socialnetwork.impl.SocialNetworkImpl Social Network}' class. + * + * + * @see socialnetwork.impl.SocialNetworkImpl + * @see socialnetwork.impl.SocialnetworkPackageImpl#getSocialNetwork() + * @generated + */ + EClass SOCIAL_NETWORK = eINSTANCE.getSocialNetwork(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute SOCIAL_NETWORK__NAME = eINSTANCE.getSocialNetwork_Name(); + + /** + * The meta object literal for the 'Persons' containment reference list feature. + * + * + * @generated + */ + EReference SOCIAL_NETWORK__PERSONS = eINSTANCE.getSocialNetwork_Persons(); + + /** + * The meta object literal for the '{@link socialnetwork.impl.PersonImpl Person}' class. + * + * + * @see socialnetwork.impl.PersonImpl + * @see socialnetwork.impl.SocialnetworkPackageImpl#getPerson() + * @generated + */ + EClass PERSON = eINSTANCE.getPerson(); + + /** + * The meta object literal for the 'Friends' reference list feature. + * + * + * @generated + */ + EReference PERSON__FRIENDS = eINSTANCE.getPerson_Friends(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute PERSON__NAME = eINSTANCE.getPerson_Name(); + + } + +} //SocialnetworkPackage diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/PersonImpl.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/PersonImpl.java new file mode 100644 index 00000000..d8bab731 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/PersonImpl.java @@ -0,0 +1,208 @@ +/** + */ +package socialnetwork.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +import socialnetwork.Person; +import socialnetwork.SocialnetworkPackage; + +/** + * + * An implementation of the model object 'Person'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link socialnetwork.impl.PersonImpl#getFriends Friends}
  • + *
  • {@link socialnetwork.impl.PersonImpl#getName Name}
  • + *
+ * + * @generated + */ +public class PersonImpl extends MinimalEObjectImpl.Container implements Person { + /** + * The cached value of the '{@link #getFriends() Friends}' reference list. + * + * + * @see #getFriends() + * @generated + * @ordered + */ + protected EList friends; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = "Name"; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * + * + * @generated + */ + protected PersonImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return SocialnetworkPackage.Literals.PERSON; + } + + /** + * + * + * @generated + */ + @Override + public EList getFriends() { + if (friends == null) { + friends = new EObjectResolvingEList(Person.class, this, SocialnetworkPackage.PERSON__FRIENDS); + } + return friends; + } + + /** + * + * + * @generated + */ + @Override + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + @Override + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SocialnetworkPackage.PERSON__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case SocialnetworkPackage.PERSON__FRIENDS: + return getFriends(); + case SocialnetworkPackage.PERSON__NAME: + return getName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case SocialnetworkPackage.PERSON__FRIENDS: + getFriends().clear(); + getFriends().addAll((Collection) newValue); + return; + case SocialnetworkPackage.PERSON__NAME: + setName((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case SocialnetworkPackage.PERSON__FRIENDS: + getFriends().clear(); + return; + case SocialnetworkPackage.PERSON__NAME: + setName(NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case SocialnetworkPackage.PERSON__FRIENDS: + return friends != null && !friends.isEmpty(); + case SocialnetworkPackage.PERSON__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //PersonImpl diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialNetworkImpl.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialNetworkImpl.java new file mode 100644 index 00000000..cb28b749 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialNetworkImpl.java @@ -0,0 +1,228 @@ +/** + */ +package socialnetwork.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import socialnetwork.Person; +import socialnetwork.SocialNetwork; +import socialnetwork.SocialnetworkPackage; + +/** + * + * An implementation of the model object 'Social Network'. + * + *

+ * The following features are implemented: + *

+ *
    + *
  • {@link socialnetwork.impl.SocialNetworkImpl#getName Name}
  • + *
  • {@link socialnetwork.impl.SocialNetworkImpl#getPersons Persons}
  • + *
+ * + * @generated + */ +public class SocialNetworkImpl extends MinimalEObjectImpl.Container implements SocialNetwork { + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = "SocialNetwork"; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getPersons() Persons}' containment reference list. + * + * + * @see #getPersons() + * @generated + * @ordered + */ + protected EList persons; + + /** + * + * + * @generated + */ + protected SocialNetworkImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return SocialnetworkPackage.Literals.SOCIAL_NETWORK; + } + + /** + * + * + * @generated + */ + @Override + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + @Override + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SocialnetworkPackage.SOCIAL_NETWORK__NAME, oldName, + name)); + } + + /** + * + * + * @generated + */ + @Override + public EList getPersons() { + if (persons == null) { + persons = new EObjectContainmentEList(Person.class, this, + SocialnetworkPackage.SOCIAL_NETWORK__PERSONS); + } + return persons; + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case SocialnetworkPackage.SOCIAL_NETWORK__PERSONS: + return ((InternalEList) getPersons()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case SocialnetworkPackage.SOCIAL_NETWORK__NAME: + return getName(); + case SocialnetworkPackage.SOCIAL_NETWORK__PERSONS: + return getPersons(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case SocialnetworkPackage.SOCIAL_NETWORK__NAME: + setName((String) newValue); + return; + case SocialnetworkPackage.SOCIAL_NETWORK__PERSONS: + getPersons().clear(); + getPersons().addAll((Collection) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case SocialnetworkPackage.SOCIAL_NETWORK__NAME: + setName(NAME_EDEFAULT); + return; + case SocialnetworkPackage.SOCIAL_NETWORK__PERSONS: + getPersons().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case SocialnetworkPackage.SOCIAL_NETWORK__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case SocialnetworkPackage.SOCIAL_NETWORK__PERSONS: + return persons != null && !persons.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) + return super.toString(); + + StringBuilder result = new StringBuilder(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //SocialNetworkImpl diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkFactoryImpl.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkFactoryImpl.java new file mode 100644 index 00000000..87fa3a87 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkFactoryImpl.java @@ -0,0 +1,111 @@ +/** + */ +package socialnetwork.impl; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import socialnetwork.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SocialnetworkFactoryImpl extends EFactoryImpl implements SocialnetworkFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static SocialnetworkFactory init() { + try { + SocialnetworkFactory theSocialnetworkFactory = (SocialnetworkFactory) EPackage.Registry.INSTANCE + .getEFactory(SocialnetworkPackage.eNS_URI); + if (theSocialnetworkFactory != null) { + return theSocialnetworkFactory; + } + } catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new SocialnetworkFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SocialnetworkFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case SocialnetworkPackage.SOCIAL_NETWORK: + return createSocialNetwork(); + case SocialnetworkPackage.PERSON: + return createPerson(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + @Override + public SocialNetwork createSocialNetwork() { + SocialNetworkImpl socialNetwork = new SocialNetworkImpl(); + return socialNetwork; + } + + /** + * + * + * @generated + */ + @Override + public Person createPerson() { + PersonImpl person = new PersonImpl(); + return person; + } + + /** + * + * + * @generated + */ + @Override + public SocialnetworkPackage getSocialnetworkPackage() { + return (SocialnetworkPackage) getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static SocialnetworkPackage getPackage() { + return SocialnetworkPackage.eINSTANCE; + } + +} //SocialnetworkFactoryImpl diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkPackageImpl.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkPackageImpl.java new file mode 100644 index 00000000..7588df50 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/impl/SocialnetworkPackageImpl.java @@ -0,0 +1,267 @@ +/** + */ +package socialnetwork.impl; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import socialnetwork.Person; +import socialnetwork.SocialNetwork; +import socialnetwork.SocialnetworkFactory; +import socialnetwork.SocialnetworkPackage; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class SocialnetworkPackageImpl extends EPackageImpl implements SocialnetworkPackage { + /** + * + * + * @generated + */ + private EClass socialNetworkEClass = null; + + /** + * + * + * @generated + */ + private EClass personEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see socialnetwork.SocialnetworkPackage#eNS_URI + * @see #init() + * @generated + */ + private SocialnetworkPackageImpl() { + super(eNS_URI, SocialnetworkFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

This method is used to initialize {@link SocialnetworkPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SocialnetworkPackage init() { + if (isInited) + return (SocialnetworkPackage) EPackage.Registry.INSTANCE.getEPackage(SocialnetworkPackage.eNS_URI); + + // Obtain or create and register package + Object registeredSocialnetworkPackage = EPackage.Registry.INSTANCE.get(eNS_URI); + SocialnetworkPackageImpl theSocialnetworkPackage = registeredSocialnetworkPackage instanceof SocialnetworkPackageImpl + ? (SocialnetworkPackageImpl) registeredSocialnetworkPackage + : new SocialnetworkPackageImpl(); + + isInited = true; + + // Create package meta-data objects + theSocialnetworkPackage.createPackageContents(); + + // Initialize created meta-data + theSocialnetworkPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSocialnetworkPackage.freeze(); + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(SocialnetworkPackage.eNS_URI, theSocialnetworkPackage); + return theSocialnetworkPackage; + } + + /** + * + * + * @generated + */ + @Override + public EClass getSocialNetwork() { + return socialNetworkEClass; + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getSocialNetwork_Name() { + return (EAttribute) socialNetworkEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EReference getSocialNetwork_Persons() { + return (EReference) socialNetworkEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public EClass getPerson() { + return personEClass; + } + + /** + * + * + * @generated + */ + @Override + public EReference getPerson_Friends() { + return (EReference) personEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + @Override + public EAttribute getPerson_Name() { + return (EAttribute) personEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + @Override + public SocialnetworkFactory getSocialnetworkFactory() { + return (SocialnetworkFactory) getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) + return; + isCreated = true; + + // Create classes and their features + socialNetworkEClass = createEClass(SOCIAL_NETWORK); + createEAttribute(socialNetworkEClass, SOCIAL_NETWORK__NAME); + createEReference(socialNetworkEClass, SOCIAL_NETWORK__PERSONS); + + personEClass = createEClass(PERSON); + createEReference(personEClass, PERSON__FRIENDS); + createEAttribute(personEClass, PERSON__NAME); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) + return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(socialNetworkEClass, SocialNetwork.class, "SocialNetwork", !IS_ABSTRACT, !IS_INTERFACE, + IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getSocialNetwork_Name(), ecorePackage.getEString(), "name", "SocialNetwork", 0, 1, + SocialNetwork.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, + !IS_DERIVED, IS_ORDERED); + initEReference(getSocialNetwork_Persons(), this.getPerson(), null, "persons", null, 0, -1, SocialNetwork.class, + !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, + IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(personEClass, Person.class, "Person", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getPerson_Friends(), this.getPerson(), null, "friends", null, 0, -1, Person.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + initEAttribute(getPerson_Name(), ecorePackage.getEString(), "name", "Name", 0, 1, Person.class, !IS_TRANSIENT, + !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http://www.eclipse.org/emf/2002/Ecore + createEcoreAnnotations(); + } + + /** + * Initializes the annotations for http://www.eclipse.org/emf/2002/Ecore. + * + * + * @generated + */ + protected void createEcoreAnnotations() { + String source = "http://www.eclipse.org/emf/2002/Ecore"; + addAnnotation(this, source, new String[] {}); + } + +} //SocialnetworkPackageImpl diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkAdapterFactory.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkAdapterFactory.java new file mode 100644 index 00000000..0dd30975 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkAdapterFactory.java @@ -0,0 +1,138 @@ +/** + */ +package socialnetwork.util; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +import socialnetwork.*; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see socialnetwork.SocialnetworkPackage + * @generated + */ +public class SocialnetworkAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static SocialnetworkPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public SocialnetworkAdapterFactory() { + if (modelPackage == null) { + modelPackage = SocialnetworkPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject) object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected SocialnetworkSwitch modelSwitch = new SocialnetworkSwitch() { + @Override + public Adapter caseSocialNetwork(SocialNetwork object) { + return createSocialNetworkAdapter(); + } + + @Override + public Adapter casePerson(Person object) { + return createPersonAdapter(); + } + + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject) target); + } + + /** + * Creates a new adapter for an object of class '{@link socialnetwork.SocialNetwork Social Network}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see socialnetwork.SocialNetwork + * @generated + */ + public Adapter createSocialNetworkAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link socialnetwork.Person Person}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see socialnetwork.Person + * @generated + */ + public Adapter createPersonAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //SocialnetworkAdapterFactory diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkSwitch.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkSwitch.java new file mode 100644 index 00000000..00d7955c --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/encore_gen/socialnetwork/util/SocialnetworkSwitch.java @@ -0,0 +1,134 @@ +/** + */ +package socialnetwork.util; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +import socialnetwork.*; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see socialnetwork.SocialnetworkPackage + * @generated + */ +public class SocialnetworkSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static SocialnetworkPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public SocialnetworkSwitch() { + if (modelPackage == null) { + modelPackage = SocialnetworkPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @param ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case SocialnetworkPackage.SOCIAL_NETWORK: { + SocialNetwork socialNetwork = (SocialNetwork) theEObject; + T result = caseSocialNetwork(socialNetwork); + if (result == null) + result = defaultCase(theEObject); + return result; + } + case SocialnetworkPackage.PERSON: { + Person person = (Person) theEObject; + T result = casePerson(person); + if (result == null) + result = defaultCase(theEObject); + return result; + } + default: + return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Social Network'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Social Network'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSocialNetwork(SocialNetwork object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Person'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Person'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T casePerson(Person object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //SocialnetworkSwitch diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/generator.vqgen b/Metrics/Metrics-Calculation/SocialNetwork_plugin/generator.vqgen new file mode 100644 index 00000000..902285d1 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/generator.vqgen @@ -0,0 +1 @@ +genmodel "platform:/resource/SocialNetwork_plugin/model/socialnetwork.genmodel" \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/inputs/.gitignore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/inputs/.gitignore new file mode 100644 index 00000000..17126b28 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/inputs/.gitignore @@ -0,0 +1,4 @@ +# ignore everything in this folder except for this folder it self + +* +!.gitignore \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.aird b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.aird new file mode 100644 index 00000000..e7e28ecd --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.aird @@ -0,0 +1,183 @@ + + + + socialnetwork.ecore + socialnetwork.genmodel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + KEEP_LOCATION + KEEP_SIZE + KEEP_RATIO + + + + + + + + + + + + + + + + + + + labelSize + + + labelSize + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.ecore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.ecore new file mode 100644 index 00000000..cacf9921 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.ecore @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.genmodel b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.genmodel new file mode 100644 index 00000000..c9515653 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/socialnetwork.genmodel @@ -0,0 +1,21 @@ + + + socialnetwork.ecore + + + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/200_nodes.jpg b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/200_nodes.jpg new file mode 100644 index 00000000..a35c291b Binary files /dev/null and b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/200_nodes.jpg differ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/220_nodes.jpg b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/220_nodes.jpg new file mode 100644 index 00000000..4d41dff7 Binary files /dev/null and b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/220_nodes.jpg differ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/260_nodes.jpg b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/260_nodes.jpg new file mode 100644 index 00000000..b16cdfb2 Binary files /dev/null and b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/260_nodes.jpg differ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/280_nodes.jpg b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/280_nodes.jpg new file mode 100644 index 00000000..16c0ee23 Binary files /dev/null and b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/280_nodes.jpg differ diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/output.txt b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/output.txt new file mode 100644 index 00000000..35158e20 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/output.txt @@ -0,0 +1,300 @@ +1 +9 +7 +0 +4 +6 +16 +0 +2 +4 +17 +20 +1 +5 +2 +3 +11 +6 +4 +0 +2 +1 +3 +5 +9 +13 +11 +0 +1 +10 +3 +0 +1 +1 +0 +17 +0 +4 +2 +0 +1 +10 +10 +0 +24 +9 +0 +14 +1 +11 +2 +17 +3 +3 +3 +0 +3 +1 +3 +2 +2 +1 +0 +3 +6 +3 +16 +3 +10 +6 +6 +6 +11 +6 +10 +20 +1 +4 +13 +0 +0 +3 +2 +0 +12 +0 +0 +22 +4 +0 +0 +20 +1 +10 +9 +11 +5 +27 +1 +3 +9 +0 +23 +10 +9 +23 +0 +3 +7 +2 +0 +9 +3 +0 +12 +11 +7 +6 +9 +2 +0 +3 +4 +3 +9 +3 +0 +7 +2 +1 +9 +1 +11 +6 +5 +16 +0 +19 +14 +9 +13 +2 +8 +0 +6 +1 +1 +2 +0 +3 +15 +3 +0 +3 +17 +1 +15 +5 +1 +21 +8 +2 +7 +3 +16 +11 +1 +5 +1 +5 +1 +6 +3 +16 +6 +17 +3 +5 +7 +2 +9 +2 +1 +11 +1 +0 +3 +5 +6 +2 +5 +1 +4 +9 +0 +11 +1 +10 +13 +6 +2 +1 +3 +4 +0 +1 +2 +10 +12 +3 +3 +3 +0 +2 +4 +2 +18 +3 +8 +7 +5 +3 +16 +1 +4 +8 +15 +1 +11 +15 +1 +8 +7 +1 +2 +0 +9 +5 +2 +1 +3 +6 +4 +8 +3 +12 +4 +21 +9 +2 +3 +2 +1 +3 +11 +2 +9 +0 +10 +6 +1 +2 +0 +8 +5 +2 +3 +8 +1 +13 +8 +2 +2 +11 +4 +21 +6 +5 +0 +8 +8 +12 +0 +0 +4 +1 +19 +5 +3 +1 +3 +12 +2 +6 +11 +8 +8 +2 +18 +0 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/plot_distribution.m b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/plot_distribution.m new file mode 100644 index 00000000..4c67a191 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/model/statistics/plot_distribution.m @@ -0,0 +1,11 @@ +clear; +clc; + +matrix = load('-ascii', "output.txt"); +hist(matrix,unique(matrix)); +hold on; +[a,b] = hist(matrix,unique(matrix)) +plot(b, a) +hold off; +sum(matrix) +average = sum(matrix) / length(matrix) \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/output.txt b/Metrics/Metrics-Calculation/SocialNetwork_plugin/output.txt new file mode 100644 index 00000000..f027494d --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/output.txt @@ -0,0 +1,9 @@ +1 +3 +1 +3 +3 +5 +3 +1 +2 diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/output/.gitignore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/output/.gitignore new file mode 100644 index 00000000..17126b28 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/output/.gitignore @@ -0,0 +1,4 @@ +# ignore everything in this folder except for this folder it self + +* +!.gitignore \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.properties b/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.properties new file mode 100644 index 00000000..a6a0df71 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = SocialNetwork_plugin +providerName = www.example.org diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.xml b/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.xml new file mode 100644 index 00000000..6f4ab31b --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/plugin.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src-gen/ca/mcgill/ecse/socialnetwork/plugin/.gitignore b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src-gen/ca/mcgill/ecse/socialnetwork/plugin/.gitignore new file mode 100644 index 00000000..f2558cf5 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src-gen/ca/mcgill/ecse/socialnetwork/plugin/.gitignore @@ -0,0 +1,10 @@ +/.Friendship.java._trace +/.NoFriend.java._trace +/.Queries.java._trace +/.SelfFriend.java._trace +/.SingleFriendship.java._trace +/Friendship.java +/NoFriend.java +/Queries.java +/SelfFriend.java +/SingleFriendship.java diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/plugin/Queries.vql b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/plugin/Queries.vql new file mode 100644 index 00000000..3e7fc68c --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/plugin/Queries.vql @@ -0,0 +1,54 @@ +package ca.mcgill.ecse.socialnetwork.plugin + +import epackage "http://ecse.mcgill.ca/socialnetwork" + +//@Constraint(message="terminatorAndInformation", severity="error", key={T}) +//pattern terminatorAndInformation(T : FAMTerminator, I : InformationLink) = { +// FunctionalOutput.outgoingLinks(Out,I); +// FunctionalOutput.terminator(Out,T); +//} or { +// InformationLink.to(I,In); +// FunctionalInput.terminator(In,T); +//} + +@Constraint(message="singleFriendship", severity="error", key={p1}) +pattern singleFriendship(p1: Person) { + find friendship(p1, p); + neg find friendship(p, p1); +} + +//@Constraint(message="cycle", severity="error", key={p}) +//pattern cycleInParenthood(p: Person) { +// find isAncestor(p, p); +//} + +@Constraint(message="noFriend", severity="error", key={p}) +pattern noFriend(p: Person){ + neg find friendship(p, _); +} + +//@Constraint(message="brothhoodParent", severity="error", key={p1,p2}) +//pattern brothhoodParent(p1: Person, p2: Person){ +// Person.parents(p1, parent1); +// Person.parents(p2, parent2); +// parent1 == parent2; +// find isAncestor(p1, p2); +//} +@Constraint(message="selfFriend", severity="error", key={p}) +pattern selfFriend(p: Person){ + Person.friends(p,p); +} + +pattern friendship(p1: Person, p2: Person){ + Person.friends(p1,p2); +} + +//pattern isAncestor(person : Person, ancestor : Person){ +// Person.parents(person, ancestor); +//} or { +// Person.parents(person, parent); +// find isAncestor(parent, ancestor); +//} + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java new file mode 100644 index 00000000..72ea45d1 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Main.java @@ -0,0 +1,128 @@ +package ca.mcgill.ecse.socialnetwork.runner; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.PrintStream; +import java.util.ArrayList; + +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.app.Domain; +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.distance.KSDistance; +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.graph.EMFGraph; +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.CsvFileWriter; +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.io.GraphReader; +import ca.mcgill.ecse.dslreasoner.realistic.metrics.calculator.metrics.MetricSampleGroup; +import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.validation.ViolationCheck; +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage; +import socialnetwork.Person; + +public class Main { + + private static String runWithPath(String path) { + String message = StandaloneScriptExecutor.executeScript(path); + return message; + } + + public static void main(String args[]) { +// try { + + ArrayList> output = new ArrayList>(); + output.add(prepareInfo()); + CsvFileWriter.write(output, "yakinduum/info.csv"); + //YakinduumModel.init(); + generateModel(1); +// }catch(Exception e) { +// e.printStackTrace(); +// }finally { +// outDegreeStatistic(); +// } +// outDegreeStatistic(); + + } + + public static void generateModel(int run) { + //prepare initial info + long begin = System.currentTimeMillis(); + String message = runWithPath("yakinduGeneration.vsconfig"); + + + + if(message == null) { + ArrayList> output = new ArrayList>(); + long elapsed = System.currentTimeMillis() - begin; + String time = formatTime(elapsed); + + ArrayList infoOutput = new ArrayList(); + infoOutput.add(run+ ""); + infoOutput.add(time); + infoOutput.addAll(calculateMetric()); + + YakinduumModel model = new YakinduumModel("output/Viatra_100/1.xmi"); + int violationCount = ViolationCheck.calculateViolationCounts(model.yakinduum); + infoOutput.add(violationCount + ""); + + //save model to another directory + model.save("yakinduum/" + run + ".xmi"); + + output.add(infoOutput); + CsvFileWriter.append(output, "yakinduum/info.csv"); + System.out.println("Finished"); + } + + } + + public static ArrayList calculateMetric() { + //read model and metric + ArrayList output = new ArrayList(); + GraphReader reader = new GraphReader(YakindummPackage.eINSTANCE); + EMFGraph graph = reader.readModels("output/Viatra_100/").get(0); + + //KS distance + KSDistance ks = new KSDistance(Domain.Yakinduum); + + //calculate and put metric data to output array + MetricSampleGroup samples = graph.evaluateAllMetricsToSamples(); + output.add(graph.getStatistic().getAllNodes().size() + ""); + output.add(ks.outDegreeDistance(samples.outDegreeSamples) + ""); + output.add(ks.naDistance(samples.naSamples)+ ""); + output.add(ks.mpcDistance(samples.mpcSamples) + ""); + return output; + } + + public static ArrayList prepareInfo() { + ArrayList info = new ArrayList(); + info.add("ID"); + info.add("Time"); + info.add("# of Nodes"); + info.add("Out Degree"); + info.add("Node Activity"); + info.add("MPC"); + info.add("Violations"); + return info; + } + + public static String formatTime(long time) { + long mili = time % 1000; + long second = (time / 1000) % 60; + long minute = (time / (1000 * 60)); + return String.format("%d : %d.%d", minute, second, mili); + } + + public static void statistics() { + String uri = "output/1.xmi"; + SocialNetworkModel socialNetwork = new SocialNetworkModel(uri); + System.out.println(socialNetwork.getPersons().size()); + + File file = new File("model/statistics/output.txt"); + try { + @SuppressWarnings("resource") + PrintStream out = new PrintStream(file); + for(Person p : socialNetwork.getPersons()) { + out.println(p.getFriends().size()); + } + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + System.out.println("Output Finished"); + } +} diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Persisitence.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Persisitence.java new file mode 100644 index 00000000..3ebede25 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/Persisitence.java @@ -0,0 +1,63 @@ +package ca.mcgill.ecse.socialnetwork.runner; +import java.io.IOException; +import java.util.Collections; +import java.util.Map; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + +public class Persisitence { + private String uri; + + public Persisitence (String suffix, String uri){ + //prepare to save + Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; + Map m = reg.getExtensionToFactoryMap(); + m.put(suffix, new XMIResourceFactoryImpl()); + this.uri = uri; + } + + + /** + * Save the model + * @return whether the model has saved successfully + */ + public boolean save(G model) { + //create resource + ResourceSet resSet = new ResourceSetImpl(); + Resource resource = resSet.createResource(URI.createURI(uri)); + resource.getContents().add(model); + try { + resource.save(Collections.EMPTY_MAP); + return true; + }catch(IOException e) { + e.printStackTrace(); + return false; + } + } + + /** + * load the model from persistent + * @return: the model loaded + */ + @SuppressWarnings("unchecked") + public G load() { + G model = null; +// try { + ResourceSet resSet = new ResourceSetImpl(); + Resource resource = resSet.getResource(URI.createURI(uri), true); + model = (G) resource.getContents().get(0); +// }catch (org.eclipse.emf.common.util.WrappedException e) { +// // if the file cannot be found then return null +// if(e.getCause().getClass() == java.io.FileNotFoundException.class) { +// return null; +// } +// } + + return model; + } +} diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/RunnerTests.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/RunnerTests.java new file mode 100644 index 00000000..c09c55be --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/RunnerTests.java @@ -0,0 +1,18 @@ +package ca.mcgill.ecse.socialnetwork.runner; + +import org.junit.Test; + +import hu.bme.mit.inf.dslreasoner.application.execution.StandaloneScriptExecutor; + +public class RunnerTests { + private static String runWithPath(String path) { + String message = StandaloneScriptExecutor.executeScript(path); + return message; + } + + @Test + public void generateModel() { + String message = runWithPath("SocialNetworkGeneration.vsconfig"); + System.out.println(message); + } +} diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/SocialNetworkModel.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/SocialNetworkModel.java new file mode 100644 index 00000000..51c50b11 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/SocialNetworkModel.java @@ -0,0 +1,62 @@ +package ca.mcgill.ecse.socialnetwork.runner; + +import org.eclipse.emf.common.util.EList; + +import socialnetwork.Person; +import socialnetwork.SocialNetwork; +import socialnetwork.SocialnetworkFactory; +import socialnetwork.SocialnetworkPackage; +import socialnetwork.impl.SocialnetworkFactoryImpl; + + + +public class SocialNetworkModel { + private final static String SUFFIX = "xmi"; + + private static boolean isInit = false; + + public static void init() { + SocialnetworkFactory.eINSTANCE.eClass(); + SocialnetworkPackage.eINSTANCE.eClass(); + SocialnetworkFactoryImpl.init(); + } + + // container for the social network model + public SocialNetwork socialNetwork; + + // factory for social network model + SocialnetworkFactory factory; + + // persistent + Persisitence persistence; + + + public SocialNetworkModel(String uri){ + if(!isInit) { + init(); + } + + //create persistence + persistence = new Persisitence(SUFFIX, uri); + factory = SocialnetworkFactory.eINSTANCE; + // try load the model + this.socialNetwork = persistence.load(); + if(this.socialNetwork == null) { + this.socialNetwork = factory.createSocialNetwork(); + } + } + + public Person createPerson() { + Person p = factory.createPerson(); + socialNetwork.getPersons().add(p); + return p; + } + + public EList getPersons(){ + return socialNetwork.getPersons(); + } + + public boolean save() { + return persistence.save(socialNetwork); + } +} diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/YakinduumModel.java b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/YakinduumModel.java new file mode 100644 index 00000000..803daff4 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/src/ca/mcgill/ecse/socialnetwork/runner/YakinduumModel.java @@ -0,0 +1,52 @@ +package ca.mcgill.ecse.socialnetwork.runner; + +import javax.annotation.Resource; + +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.Statechart; +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummFactory; +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage; +import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.impl.YakindummFactoryImpl; +import socialnetwork.SocialNetwork; +import socialnetwork.SocialnetworkFactory; + +public class YakinduumModel { + private final static String SUFFIX = "xmi"; + + private static boolean isInit = false; + + private String uri; + + public static void init() { + YakindummFactory.eINSTANCE.eClass(); + YakindummPackage.eINSTANCE.eClass(); + YakindummFactoryImpl.init(); + } + + // container for the social network model + public Statechart yakinduum; + + + // persistent + Persisitence persistence; + + + public YakinduumModel(String uri){ + if(!isInit) { + init(); + } + this.uri = uri; + //create persistence + persistence = new Persisitence(SUFFIX, uri); + // try load the model + this.yakinduum = persistence.load(); + } + + public boolean save(String uri) { + if(this.uri.equals(uri)) { + return persistence.save(yakinduum); + }else { + persistence = new Persisitence(SUFFIX, uri); + return persistence.save(yakinduum); + } + } +} diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduGeneration.vsconfig b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduGeneration.vsconfig new file mode 100644 index 00000000..cf08c562 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduGeneration.vsconfig @@ -0,0 +1,23 @@ +import epackage "../VIATRA-Generator/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/model/yakindu_simplified.ecore" +import viatra "../VIATRA-Generator/Domains/hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph/queries/hu/bme/mit/inf/dslreasoner/partialsnapshot_mavo/yakindu/patterns.vql" + +generate { + metamodel = { package yakindumm excluding { Synchronization}} + constraints = { package hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu } + partial-model = { "inputs/start.xmi"} + + solver = ViatraSolver + + scope = { + #node = 100 + } + + number = 1 + runs = 1 + config = { + log-level = none + } + + debug = "debug" + output = "output/Viatra_100/" +} \ No newline at end of file diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/1.xmi b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/1.xmi new file mode 100644 index 00000000..6bee747f --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/1.xmi @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/info.csv b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/info.csv new file mode 100644 index 00000000..e11b75f9 --- /dev/null +++ b/Metrics/Metrics-Calculation/SocialNetwork_plugin/yakinduum/info.csv @@ -0,0 +1,2 @@ +ID,Time,# of Nodes,Out Degree,Node Activity,MPC,Violations +1,3 : 50.959,100,0.031818181818181815,0.10775510204081633,0.10059701492537314,4 -- cgit v1.2.3-54-g00ecf