diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..aca7d486 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.metadata +/.recommenders diff --git a/Dependencies/.gitignore b/Dependencies/.gitignore new file mode 100644 index 00000000..6b95a456 --- /dev/null +++ b/Dependencies/.gitignore @@ -0,0 +1,4 @@ +/saripaar +/ActiveAndroid +/androidannotations +/evo-inflector diff --git a/Dependencies/README.md b/Dependencies/README.md new file mode 100644 index 00000000..99407b87 --- /dev/null +++ b/Dependencies/README.md @@ -0,0 +1,7 @@ +/ActiveAndroid => https://github.com/smaugho/ActiveAndroid.git :branch = declex +
+/androidannotations => https://github.com/smaugho/androidannotations.git :branch = declex +
+/sapiraar => https://github.com/smaugho/android-saripaar.git :branch = declex +
+/evo-inflector => https://github.com/atteo/evo-inflector.git :branch = master diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..26bd39bc --- /dev/null +++ b/LICENSE @@ -0,0 +1,37 @@ +************************************ +This project is available under the following license: +************************************ +Copyright (C) 2016 DSpot Sp. z o.o + +Licensed under the Apache License, Version 2.0 (the "License"); you may not +use this file except in compliance with the License. You may obtain a copy of +the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +License for the specific language governing permissions and limitations under +the License. + +This project uses CodeModel (http://codemodel.java.net/), which is +distributed under the GlassFish Dual License, which means CodeModel is +subject to the terms of either the GNU General Public License Version 2 only +("GPL") or the Common Development and Distribution License("CDDL"). + +You may obtain a copy of the "CDDL" License at + +http://www.opensource.org/licenses/cddl1.php + +As per section 3.6 ("Larger Works") of the "CDDL" License, we may create a +Larger Work by combining Covered Software with other code not governed by +the terms of this License and distribute the Larger Work as a single +product. + +We are therefore allowed to distribute CodeModel without Modification as +part of AndroidAnnotations. + +About AndroidAnnotations generated files: if you create a larger work that +contains files generated by AndroidAnnotations, you can distribute that work +under terms of your choice. diff --git a/README.md b/README.md new file mode 100644 index 00000000..54282019 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +# DecleX + +DecleX is a framework that aims to get closer to the idea of a fully Declarative Language for Android Development. +It is totally based on AndroidAnnotations; in a similar fashion, we want to facilitate the writing and the maintenance of +Android applications to the highest level which has not been achieved up to now. + + +## Documentation + +Please consult our Wiki in https://github.com/smaugho/declex/wiki + +## Configuration + +Download the library jar files from [here](https://github.com/smaugho/declex/releases/tag/v1.0): + +* Place the core processor declex-v1.0.jar in a folder named compile-libs in your project. + +* Place the API file declex-api.jar in a folder named libs in your project. + +* Place the following lines in your build.graddle file: + +```graddle +apply plugin: 'com.neenbedankt.android-apt' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' + } +} + +apt { + arguments { + androidManifestFile variant.outputs[0].processResources.manifestFile + resourcePackageName 'YOUR PROJECT PACKAGE' + } +} + +``` +You should replace "YOUR PROJECT PACKAGE" by your project package name (Ex. com.company.example). + +* And finally add to your dependencies the framework libraries: + +```graddle +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + apt files('compile-libs/declex-v1.0.jar') + + ... +``` + +And that's it!... + +----------- +Sponsored by DSpot Sp. z o.o. Contact us at info@dspot.com.pl diff --git a/declex-api/.classpath b/declex-api/.classpath new file mode 100644 index 00000000..a6fd6cd4 --- /dev/null +++ b/declex-api/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/declex-api/.gitignore b/declex-api/.gitignore new file mode 100644 index 00000000..424645e9 --- /dev/null +++ b/declex-api/.gitignore @@ -0,0 +1,4 @@ +/bin +/.settings +/.declex +/target/ diff --git a/declex-api/.project b/declex-api/.project new file mode 100644 index 00000000..c307760f --- /dev/null +++ b/declex-api/.project @@ -0,0 +1,40 @@ + + + declex-api + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + + + ActiveAndroid + 2 + WORKSPACE_LOC/Dependencies/ActiveAndroid/src + + + androidannotations-api + 2 + WORKSPACE_LOC/Dependencies/androidannotations/AndroidAnnotations/androidannotations-core/androidannotations-api/src/main/java + + + saripaar + 2 + WORKSPACE_LOC/Dependencies/saripaar/saripaar/src/main/java + + + diff --git a/declex-api/build.xml b/declex-api/build.xml new file mode 100644 index 00000000..f728695a --- /dev/null +++ b/declex-api/build.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Compiling Built-In Actions ${class.path} + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/declex-api/libs/android-support-v4.jar b/declex-api/libs/android-support-v4.jar new file mode 100644 index 00000000..428bdbc0 Binary files /dev/null and b/declex-api/libs/android-support-v4.jar differ diff --git a/declex-api/libs/android.jar b/declex-api/libs/android.jar new file mode 100644 index 00000000..4274d2b0 Binary files /dev/null and b/declex-api/libs/android.jar differ diff --git a/declex-api/libs/eventbus-3.0.0.jar b/declex-api/libs/eventbus-3.0.0.jar new file mode 100644 index 00000000..38c496fe Binary files /dev/null and b/declex-api/libs/eventbus-3.0.0.jar differ diff --git a/declex-api/libs/jcodemodel-2.8.0.jar b/declex-api/libs/jcodemodel-2.8.0.jar new file mode 100644 index 00000000..0a0b21f9 Binary files /dev/null and b/declex-api/libs/jcodemodel-2.8.0.jar differ diff --git a/declex-api/libs/okhttp-3.4.1.jar b/declex-api/libs/okhttp-3.4.1.jar new file mode 100644 index 00000000..e31f2486 Binary files /dev/null and b/declex-api/libs/okhttp-3.4.1.jar differ diff --git a/declex-api/libs/okio-1.9.0.jar b/declex-api/libs/okio-1.9.0.jar new file mode 100644 index 00000000..3c42b934 Binary files /dev/null and b/declex-api/libs/okio-1.9.0.jar differ diff --git a/declex-api/libs/picasso-2.5.2.jar b/declex-api/libs/picasso-2.5.2.jar new file mode 100644 index 00000000..6acbaa14 Binary files /dev/null and b/declex-api/libs/picasso-2.5.2.jar differ diff --git a/declex-api/libs/support-annotations-24.0.0.jar b/declex-api/libs/support-annotations-24.0.0.jar new file mode 100644 index 00000000..ec3b6711 Binary files /dev/null and b/declex-api/libs/support-annotations-24.0.0.jar differ diff --git a/declex-api/pom.xml b/declex-api/pom.xml new file mode 100644 index 00000000..1802f7be --- /dev/null +++ b/declex-api/pom.xml @@ -0,0 +1,100 @@ + + + 4.0.0 + + com.dspot + declex-api + 1.0 + DecleX API + DecleX Framework API + + + src + + + resources + + + + + + target/processed + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + **/action/builtin/** + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + verify + + jar-no-fork + + + + + + + + + + DSpot Sp. z o.o + http://www.dspot.com.pl + + + + + bintray-declex + https://api.bintray.com/maven/dspot/declex/declex-api/;publish=1 + + + + + + com.helger + jcodemodel + 2.8.0 + compile + + + + com.google.code.gson + gson + 2.8.0 + + + com.squareup.picasso + picasso + 2.5.2 + + + org.greenrobot + eventbus + 3.0.0 + + + com.squareup.okhttp3 + okhttp + 3.4.2 + + + + + \ No newline at end of file diff --git a/declex-api/resources/declex-api.properties b/declex-api/resources/declex-api.properties new file mode 100644 index 00000000..78899610 --- /dev/null +++ b/declex-api/resources/declex-api.properties @@ -0,0 +1,18 @@ +#Mon, 07 Nov 2016 04:43:09 +0100 +# +# Copyright (C) 2010-2015 eBusiness Information, Excilys Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed To in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +version=1.0 diff --git a/declex-api/src/com/dspot/declex/api/action/Action.java b/declex-api/src/com/dspot/declex/api/action/Action.java new file mode 100644 index 00000000..060804c9 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/Action.java @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Actions are a powerful way to describe what to do after a specific action occurs. + * Typically, actions are bind to UI components, but they can be bind to events + * or methods. + * + * If you have an already built layout where you declare a button, for instance, to Login with Facebook + * and after this login is done, you want the MainActivity to be opened, this is easily archieve with the following + * declarative instruction:
+ * + * @Action + * S2 btnFacebookLogin; + * + *
+ * here, "btnFacebookLogin" is the id of the button in the layout. + *
+ * + * for UIActions, in the declaration name you can use postfix to select a specific action over the View... + * By default, it's assumed that the action will be executed after the user clicks the View. But you can use the following + * postfixes to indicate different kind of actions: + *
+ * -Click, Press, Clicked or Pressed
+ * -LongClick, LongPress, LongClicked or LongPressed
+ * 
+ * -ItemClick, ItemPress, ItemClicked, or ItemPressed
+ * -ItemLongClick, ItemLongPress, ItemLongClicked or ItemLongPressed
+ * 
+ * all these postfixes are valid. For instance: + * + * @Action("user=model") + * MainActivity gridViewItemClicked; + * + * In this case we also pass a parameter. In this case, MainActivity should accept an extra parameter named "user". + * "model" references the default model of the gridView... This is used because typically GridViews (or any other AdapterView) + * are used together a model to populate the View Items. + * + * Each action has its specific parameters, but some of them are globals. + *
+ *  ;instruction;	This executes the "instruction" code before the Action
+ *  instruction; 	Executes the "instruction" code after the Action.
+ * 
+ * + * @author Smaugh + * + */ +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface Action { + String[] value() default ""; + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/action/PutOnAction.java b/declex-api/src/com/dspot/declex/api/action/PutOnAction.java new file mode 100644 index 00000000..4d288bb7 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/PutOnAction.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface PutOnAction { + int[] value(); + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java b/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java new file mode 100644 index 00000000..ff133f09 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/ActionFor.java @@ -0,0 +1,30 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.dspot.declex.api.action.process.ActionProcessor; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface ActionFor { + String[] value(); + Class[] processors() default {}; +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java b/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java new file mode 100644 index 00000000..060d980f --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/Assignable.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface Assignable { + String value(); +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/Field.java b/declex-api/src/com/dspot/declex/api/action/annotation/Field.java new file mode 100644 index 00000000..a943affd --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/Field.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface Field { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java b/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java new file mode 100644 index 00000000..790c5575 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/annotation/FormattedExpression.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.PARAMETER) +public @interface FormattedExpression { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java new file mode 100644 index 00000000..4416da19 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/AlertDialogActionHolder.java @@ -0,0 +1,204 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import java.util.List; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Assignable; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("AlertDialog") +public class AlertDialogActionHolder { + AlertDialog.Builder builder; + + String positiveButtonText; + int positiveButtonRes; + + String negativeButtonText; + int negativeButtonRes; + + String[] multiChoiceItems; + int multiChoiceRes; + + String[] items; + int itemsRes; + + AlertDialog dialog; + + @RootContext + Context context; + + void init() { + builder = new AlertDialog.Builder(context); + } + + //Here you can infer any parameter, the first parameter is the next listener + void build(final DialogClickRunnable PositiveButtonPressed, final DialogClickRunnable NegativeButtonPressed, + final DialogClickRunnable ItemSelected, final MultiChoiceClickRunnable MultiChoiceSelected, + final Runnable Dismissed) { + + if (negativeButtonText != null) { + builder.setNegativeButton(negativeButtonText, NegativeButtonPressed); + } else if (negativeButtonRes != 0) { + builder.setNegativeButton(negativeButtonRes, NegativeButtonPressed); + } + + if (positiveButtonText != null) { + builder.setPositiveButton(positiveButtonText, PositiveButtonPressed); + } else if (positiveButtonRes != 0) { + builder.setPositiveButton(positiveButtonRes, PositiveButtonPressed); + } + + if (items != null) { + builder.setItems(items, ItemSelected); + } else if (itemsRes != 0) { + builder.setItems(itemsRes, ItemSelected); + } + + if (multiChoiceItems != null) { + builder.setMultiChoiceItems(multiChoiceItems, null, MultiChoiceSelected); + } else if (multiChoiceRes != 0) { + builder.setMultiChoiceItems(multiChoiceRes, null, MultiChoiceSelected); + } + + if (Dismissed != null) { + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + + @Override + public void onDismiss(DialogInterface arg0) { + if (Dismissed != null) Dismissed.run(); + } + }); + } + + dialog = builder.create(); + }; + + void execute() { + dialog.show(); + } + + Dialog dialog() { + return this.dialog; + } + + public AlertDialog.Builder builder() { + return this.builder; + } + + public AlertDialogActionHolder title(@FormattedExpression String title) { + builder.setTitle(title); + return this; + } + + public AlertDialogActionHolder message(@FormattedExpression String message) { + builder.setMessage(message); + return this; + } + + public AlertDialogActionHolder positiveButton(@FormattedExpression String title) { + positiveButtonText = title; + return this; + } + + public AlertDialogActionHolder positiveButton(int res) { + positiveButtonRes = res; + return this; + } + + public AlertDialogActionHolder negativeButton(@FormattedExpression String title) { + negativeButtonText = title; + return this; + } + + public AlertDialogActionHolder negativeButton(int res) { + negativeButtonRes = res; + return this; + } + + public AlertDialogActionHolder multiChoice(String ... items) { + multiChoiceItems = items; + return this; + } + + public AlertDialogActionHolder multiChoice(List items) { + multiChoiceItems = new String[items.size()]; + multiChoiceItems = items.toArray(multiChoiceItems); + return this; + } + + public AlertDialogActionHolder multiChoice(int res) { + multiChoiceRes = res; + return this; + } + + public AlertDialogActionHolder items(String ... items) { + this.items = items; + return this; + } + + public AlertDialogActionHolder items(List items) { + this.items = new String[items.size()]; + this.items = items.toArray(this.items); + return this; + } + + public AlertDialogActionHolder items(int res) { + this.itemsRes = res; + return this; + } + + public AlertDialogActionHolder into(@Assignable("dialog") Dialog dialog) { + return this; + } + + public static abstract class DialogClickRunnable implements Runnable, DialogInterface.OnClickListener { + public DialogInterface dialogInterface; + public int position; + + @Override + public void onClick(DialogInterface dialogInterface, int position) { + this.dialogInterface = dialogInterface; + this.position = position; + run(); + } + } + + public static abstract class MultiChoiceClickRunnable implements Runnable, DialogInterface.OnMultiChoiceClickListener { + public DialogInterface dialogInterface; + public int position; + public boolean checked; + + @Override + public void onClick(DialogInterface dialogInterface, int position, boolean checked) { + this.dialogInterface = dialogInterface; + this.position = position; + this.checked = checked; + run(); + } + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/BackgroundThreadActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/BackgroundThreadActionHolder.java new file mode 100644 index 00000000..66acae1c --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/BackgroundThreadActionHolder.java @@ -0,0 +1,47 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; +import org.androidannotations.api.BackgroundExecutor; + +import android.content.Context; + +import com.dspot.declex.api.action.annotation.ActionFor; + +@EBean +@ActionFor("Background") +public class BackgroundThreadActionHolder { + + @RootContext + Context context; + + Runnable Run; + + void init() { + } + + void build(Runnable Run) { + this.Run = Run; + } + + void execute() { + if(Run!=null) { + BackgroundExecutor.execute(Run); + } + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/DateDialogActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/DateDialogActionHolder.java new file mode 100644 index 00000000..a53be6dc --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/DateDialogActionHolder.java @@ -0,0 +1,121 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import java.util.Calendar; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.app.DatePickerDialog; +import android.app.Dialog; +import android.content.Context; +import android.content.DialogInterface; +import android.widget.DatePicker; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Assignable; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("DateDialog") +public class DateDialogActionHolder { + + DatePickerDialog dialog; + + @RootContext + Context context; + + private DateSetRunnable DateSet; + + void init() { + // Use the current time as the default values for the picker + final Calendar c = Calendar.getInstance(); + final int day = c.get(Calendar.DATE); + int month = c.get(Calendar.MONTH); + int year = c.get(Calendar.YEAR); + + // Create a new instance of TimePickerDialog + dialog = new DatePickerDialog( + context, + new DatePickerDialog.OnDateSetListener() { + @Override + public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { + if (DateSet != null) + DateSet.onDateSet(view, year, monthOfYear, dayOfMonth); + } + }, + year, month, day + ); + } + + //Here you can infer any parameter, the first parameter is the next listener + void build(DateSetRunnable DateSet, final Runnable Dismissed) { + this.DateSet = DateSet; + + if (Dismissed != null) { + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + + @Override + public void onDismiss(DialogInterface arg0) { + if (Dismissed != null) Dismissed.run(); + } + }); + } + + }; + + void execute() { + dialog.show(); + } + + public Dialog dialog() { + return this.dialog; + } + + public DateDialogActionHolder title(@FormattedExpression String title) { + dialog.setTitle(title); + return this; + } + + public DateDialogActionHolder message(@FormattedExpression String message) { + dialog.setMessage(message); + return this; + } + + public DateDialogActionHolder into(@Assignable("dialog") Dialog dialog) { + return this; + } + + + + public static abstract class DateSetRunnable implements Runnable, DatePickerDialog.OnDateSetListener { + + public DatePicker datePicker; + public int year; + public int month; + public int day; + + @Override + public void onDateSet(DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) { + this.datePicker = datePicker; + this.year = year; + this.month = monthOfYear; + this.day = dayOfMonth; + run(); + } + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/GetModelActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/GetModelActionHolder.java new file mode 100644 index 00000000..96141b18 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/GetModelActionHolder.java @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Field; +import com.dspot.declex.api.action.annotation.FormattedExpression; +import com.dspot.declex.api.action.processor.GetModelActionProcessor; + +@EBean +@ActionFor(value="GetModel", processors=GetModelActionProcessor.class) +public class GetModelActionHolder { + + private Runnable AfterLoad; + + void init(@Field Object object) { + } + + public GetModelActionHolder query(@FormattedExpression String query) { + return this; + } + + public GetModelActionHolder orderBy(@FormattedExpression String query) { + return this; + } + + void build(Runnable AfterLoad) { + this.AfterLoad = AfterLoad; + } + + Runnable getAfterLoad() { + return this.AfterLoad; + } + + void execute() { + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/PopulateActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/PopulateActionHolder.java new file mode 100644 index 00000000..5402545c --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/PopulateActionHolder.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Field; +import com.dspot.declex.api.action.processor.PopulateActionProcessor; + +@EBean +@ActionFor(value="Populate", processors=PopulateActionProcessor.class) +public class PopulateActionHolder { + + private Runnable Done; + + void init(@Field Object object) { + } + + void build(Runnable Done) { + this.Done = Done; + } + + void execute() { + if (Done != null) Done.run(); + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/ProgressDialogActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/ProgressDialogActionHolder.java new file mode 100644 index 00000000..667aeadc --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/ProgressDialogActionHolder.java @@ -0,0 +1,84 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.app.Dialog; +import android.app.ProgressDialog; +import android.content.Context; +import android.content.DialogInterface; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Assignable; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("ProgressDialog") +public class ProgressDialogActionHolder { + + ProgressDialog dialog; + + @RootContext + Context context; + + private Runnable Shown; + + void init() { + dialog = new ProgressDialog(context); + } + + //Here you can infer any parameter, the first parameter is the next listener + void build(Runnable Shown, final Runnable Dismissed) { + this.Shown = Shown; + + if (Dismissed != null) { + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + + @Override + public void onDismiss(DialogInterface arg0) { + if (Dismissed != null) Dismissed.run(); + } + }); + } + + }; + + void execute() { + dialog.show(); + if (Shown != null) Shown.run(); + } + + public Dialog dialog() { + return this.dialog; + } + + public ProgressDialogActionHolder title(@FormattedExpression String title) { + dialog.setTitle(title); + return this; + } + + public ProgressDialogActionHolder message(@FormattedExpression String message) { + dialog.setMessage(message); + return this; + } + + public ProgressDialogActionHolder into(@Assignable("dialog") Dialog dialog) { + return this; + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/PutModelActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/PutModelActionHolder.java new file mode 100644 index 00000000..a43de525 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/PutModelActionHolder.java @@ -0,0 +1,52 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Field; +import com.dspot.declex.api.action.annotation.FormattedExpression; +import com.dspot.declex.api.action.processor.PutModelActionProcessor; + +@EBean +@ActionFor(value="PutModel", processors=PutModelActionProcessor.class) +public class PutModelActionHolder { + + private Runnable AfterPut; + + void init(@Field Object object) { + } + + public PutModelActionHolder query(@FormattedExpression String query) { + return this; + } + + public PutModelActionHolder orderBy(@FormattedExpression String query) { + return this; + } + + void build(Runnable AfterPut) { + this.AfterPut = AfterPut; + } + + Runnable getAfterPut() { + return this.AfterPut; + } + + void execute() { + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/RecollectActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/RecollectActionHolder.java new file mode 100644 index 00000000..a10930a6 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/RecollectActionHolder.java @@ -0,0 +1,43 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Field; +import com.dspot.declex.api.action.processor.RecollectActionProcessor; + +@EBean +@ActionFor(value="Recollect", processors=RecollectActionProcessor.class) +public class RecollectActionHolder { + + private Runnable Done; + + void init(@Field Object object) { + } + + void build(Runnable Done) { + this.Done = Done; + } + + void execute() { + } + + Runnable getDone() { + return this.Done; + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/TimeDialogActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/TimeDialogActionHolder.java new file mode 100644 index 00000000..d2abf7ae --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/TimeDialogActionHolder.java @@ -0,0 +1,116 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import java.util.Calendar; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.app.Dialog; +import android.app.TimePickerDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.widget.TimePicker; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.Assignable; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("TimeDialog") +public class TimeDialogActionHolder { + + TimePickerDialog dialog; + + @RootContext + Context context; + + private TimeSetRunnable TimeSet; + + void init() { + // Use the current time as the default values for the picker + final Calendar c = Calendar.getInstance(); + int hour = c.get(Calendar.HOUR); + int minute = c.get(Calendar.MINUTE); + + // Create a new instance of TimePickerDialog and return it + dialog = new TimePickerDialog( + context, + new TimePickerDialog.OnTimeSetListener() { + @Override + public void onTimeSet(TimePicker view, int hourOfDay, int minute) { + if (TimeSet != null) + TimeSet.onTimeSet(view, hourOfDay, minute); + } + }, + hour, minute, true + ); + } + + //Here you can infer any parameter, the first parameter is the next listener + void build(TimeSetRunnable TimeSet, final Runnable Dismissed) { + this.TimeSet = TimeSet; + + if (Dismissed != null) { + dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { + + @Override + public void onDismiss(DialogInterface arg0) { + if (Dismissed != null) Dismissed.run(); + } + }); + } + + }; + + void execute() { + dialog.show(); + } + + public Dialog dialog() { + return this.dialog; + } + + public TimeDialogActionHolder title(@FormattedExpression String title) { + dialog.setTitle(title); + return this; + } + + public TimeDialogActionHolder message(@FormattedExpression String message) { + dialog.setMessage(message); + return this; + } + + public TimeDialogActionHolder into(@Assignable("dialog") Dialog dialog) { + return this; + } + + public static abstract class TimeSetRunnable implements Runnable, TimePickerDialog.OnTimeSetListener { + + public TimePicker timePicker; + public int hour; + public int minute; + + @Override + public void onTimeSet(TimePicker timePicker, int hour, int minute) { + this.timePicker = timePicker; + this.hour = hour; + this.minute = minute; + run(); + } + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/ToastActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/ToastActionHolder.java new file mode 100644 index 00000000..e1012ae8 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/ToastActionHolder.java @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.content.Context; +import android.os.Handler; +import android.os.Looper; +import android.widget.Toast; + +import com.dspot.declex.api.action.annotation.ActionFor; +import com.dspot.declex.api.action.annotation.FormattedExpression; + +@EBean +@ActionFor("Toast") +public class ToastActionHolder { + + String text; + int res; + + @RootContext + Context context; + + Runnable Shown; + + void init(@FormattedExpression String text) { + this.text = text; + } + + void init(int res) { + this.res = res; + } + + void build(Runnable Shown) { + this.Shown = Shown; + } + + void execute() { + Runnable callToast = new Runnable() { + + @Override + public void run() { + if (text != null) { + Toast.makeText(context, text, Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(context, res, Toast.LENGTH_LONG).show(); + } + if (Shown != null) Shown.run(); + } + }; + + //Thread save + if(Looper.myLooper() == Looper.getMainLooper()) { + callToast.run(); + } else { + Handler handler = new Handler(Looper.getMainLooper()); + handler.post(callToast); + } + + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/builtin/UIThreadActionHolder.java b/declex-api/src/com/dspot/declex/api/action/builtin/UIThreadActionHolder.java new file mode 100644 index 00000000..2c16ad41 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/builtin/UIThreadActionHolder.java @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.builtin; + +import org.androidannotations.annotations.EBean; +import org.androidannotations.annotations.RootContext; + +import android.content.Context; +import android.os.Handler; + +import com.dspot.declex.api.action.annotation.ActionFor; + +@EBean +@ActionFor("UIThread") +public class UIThreadActionHolder { + + @RootContext + Context context; + + Runnable Run; + + void init() { + } + + void build(Runnable Run) { + this.Run = Run; + } + + void execute() { + if(Run!=null) { + Handler mainHandler = new Handler(context.getMainLooper()); + mainHandler.post(Run); + } + } +} \ No newline at end of file diff --git a/declex-api/src/com/dspot/declex/api/action/model/BaseModelAction.java b/declex-api/src/com/dspot/declex/api/action/model/BaseModelAction.java new file mode 100644 index 00000000..fd903d4a --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/model/BaseModelAction.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.model; + +public class BaseModelAction { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/model/GetAndPutModel.java b/declex-api/src/com/dspot/declex/api/action/model/GetAndPutModel.java new file mode 100644 index 00000000..b22e350f --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/model/GetAndPutModel.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.model; + +public class GetAndPutModel extends BaseModelAction { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/model/GetModel.java b/declex-api/src/com/dspot/declex/api/action/model/GetModel.java new file mode 100644 index 00000000..cfd10863 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/model/GetModel.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.model; + +public class GetModel extends BaseModelAction { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/model/PutAndGetModel.java b/declex-api/src/com/dspot/declex/api/action/model/PutAndGetModel.java new file mode 100644 index 00000000..4cf07b90 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/model/PutAndGetModel.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.model; + +public class PutAndGetModel extends BaseModelAction { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/model/PutModel.java b/declex-api/src/com/dspot/declex/api/action/model/PutModel.java new file mode 100644 index 00000000..0f15f65a --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/model/PutModel.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.model; + +public class PutModel extends BaseModelAction { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/process/ActionInfo.java b/declex-api/src/com/dspot/declex/api/action/process/ActionInfo.java new file mode 100644 index 00000000..530e91c9 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/process/ActionInfo.java @@ -0,0 +1,62 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.process; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +public class ActionInfo { + public Map metaData; + + public List processors = new LinkedList<>(); + public Map> methods = new HashMap<>(); + + public String holderClass; + + public ActionInfo(String holderClass) { + this.holderClass = holderClass; + } + + public void addMethod(String name, String resultClass) { + addMethod(name, resultClass, new ArrayList(0)); + } + + public void addMethod(String name, String resultClass, List params) { + addMethod(name, resultClass, params, new ArrayList(0)); + } + + public void addMethod(String name, String resultClass, List params, List annotations) { + ActionMethod actionMethod = new ActionMethod(name, resultClass, params, annotations); + + List methodList = methods.get(name); + if (methodList == null) { + methodList = new LinkedList<>(); + methods.put(name, methodList); + } + + methodList.add(actionMethod); + } + + public void callProcessors() { + for (ActionProcessor processor : processors) { + processor.process(this); + } + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/process/ActionMethod.java b/declex-api/src/com/dspot/declex/api/action/process/ActionMethod.java new file mode 100644 index 00000000..19868c9b --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/process/ActionMethod.java @@ -0,0 +1,38 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.process; + +import java.lang.annotation.Annotation; +import java.util.List; +import java.util.Map; + +public class ActionMethod { + public Map metaData; + + public String name; + public List params; + public List annotations; + + public String resultClass; + + ActionMethod(String name, String resultClass, List params, List annotations) { + super(); + this.name = name; + this.params = params; + this.annotations = annotations; + this.resultClass = resultClass; + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/process/ActionMethodParam.java b/declex-api/src/com/dspot/declex/api/action/process/ActionMethodParam.java new file mode 100644 index 00000000..ebee2dd5 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/process/ActionMethodParam.java @@ -0,0 +1,42 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.process; + +import java.lang.annotation.Annotation; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.helger.jcodemodel.AbstractJClass; + +public class ActionMethodParam { + public Map metaData; + + public String name; + public AbstractJClass clazz; + public List annotations; + + public ActionMethodParam(String name, AbstractJClass clazz) { + this(name, clazz, new ArrayList(0)); + } + + public ActionMethodParam(String name, AbstractJClass clazz, List annotations) { + super(); + this.name = name; + this.clazz = clazz; + this.annotations = annotations; + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/process/ActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/process/ActionProcessor.java new file mode 100644 index 00000000..55493b2d --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/process/ActionProcessor.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.process; + +public interface ActionProcessor { + public void process(ActionInfo actionInfo); +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/ActionProcessorUtil.java b/declex-api/src/com/dspot/declex/api/action/processor/ActionProcessorUtil.java new file mode 100644 index 00000000..c37db2ac --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/ActionProcessorUtil.java @@ -0,0 +1,96 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +public class ActionProcessorUtil { + + public static T getMethodInHolder(String methodName, Object holder) { + return getMethodInHolder(methodName, holder, null); + } + + public static T getMethodInHolder(String methodName, Object holder, Object param) { + return getMethodInHolder(methodName, holder, null, param); + } + + @SuppressWarnings("unchecked") + public static T getMethodInHolder(String methodName, Object holder, String subHolder, Object param) { + Class clazz = holder.getClass(); + if (subHolder != null) { + try { + Method getPluginHolder = getMethod("getPluginHolder", clazz); + + clazz = Class.forName(subHolder); + + //It's assumed only one constructor that takes as parameter the holder + //TODO ViewsHolder doesn't follow this pattern + Constructor constructor = clazz.getDeclaredConstructors()[0]; + Object subHolderInstance = constructor.newInstance(holder); + + holder = getPluginHolder.invoke(holder, subHolderInstance); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + + } + + if (clazz == null) return null; + + Method method = getMethod(methodName, clazz); + if (method == null) return null; + + try { + if (param != null) + return (T) method.invoke(holder, param); + else { + return (T) method.invoke(holder); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } + + private static Method getMethod(String methodName, Class clazz) { + Method method = getDeclaredMethod(methodName, clazz); + if (method == null) { + Class parent = clazz.getSuperclass(); + + while (parent != null) { + method = getDeclaredMethod(methodName, parent); + if (method != null) break; + parent = parent.getSuperclass(); + } + } + + return method; + } + + private static Method getDeclaredMethod(String methodName, Class clazz) { + Method[] methods = clazz.getDeclaredMethods(); + for (Method method : methods) { + if (method.getName().equals(methodName)) { + return method; + } + } + + return null; + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/BaseActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/processor/BaseActionProcessor.java new file mode 100644 index 00000000..a44c5ed7 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/BaseActionProcessor.java @@ -0,0 +1,69 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +import com.dspot.declex.api.action.process.ActionInfo; +import com.dspot.declex.api.action.process.ActionMethod; +import com.dspot.declex.api.action.process.ActionProcessor; +import com.helger.jcodemodel.IJStatement; + +public abstract class BaseActionProcessor implements ActionProcessor { + + private ActionInfo actionInfo; + + @Override + public void process(ActionInfo actionInfo) { + this.actionInfo = actionInfo; + } + + protected ActionMethod getActionMethod(String methodName) { + return actionInfo.methods.get(methodName).get(0); + } + + protected void addPreBuildBlock(IJStatement statement) { + if (actionInfo.metaData == null) { + actionInfo.metaData = new HashMap<>(); + } + + @SuppressWarnings("unchecked") + List preBuildBlocks = (List) actionInfo.metaData.get("preBuildBlocks"); + if (preBuildBlocks == null) { + preBuildBlocks = new LinkedList<>(); + actionInfo.metaData.put("preBuildBlocks", preBuildBlocks); + } + + preBuildBlocks.add(statement); + } + + protected void addPostBuildBlock(IJStatement statement) { + if (actionInfo.metaData == null) { + actionInfo.metaData = new HashMap<>(); + } + + @SuppressWarnings("unchecked") + List postBuildBlocks = (List) actionInfo.metaData.get("postBuildBlocks"); + if (postBuildBlocks == null) { + postBuildBlocks = new LinkedList<>(); + actionInfo.metaData.put("postBuildBlocks", postBuildBlocks); + } + + postBuildBlocks.add(statement); + } +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/GetModelActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/processor/GetModelActionProcessor.java new file mode 100644 index 00000000..0f3fcc30 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/GetModelActionProcessor.java @@ -0,0 +1,95 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import static com.helger.jcodemodel.JExpr._this; +import static com.helger.jcodemodel.JExpr.direct; +import static com.helger.jcodemodel.JExpr.invoke; + +import javax.lang.model.element.Element; + +import com.dspot.declex.api.action.process.ActionInfo; +import com.dspot.declex.api.action.process.ActionMethod; +import com.dspot.declex.api.action.process.ActionMethodParam; +import com.dspot.declex.api.model.Model; +import com.dspot.declex.api.util.FormatsUtils; +import com.helger.jcodemodel.IJExpression; +import com.helger.jcodemodel.JDefinedClass; +import com.helger.jcodemodel.JInvocation; +import com.helger.jcodemodel.JMethod; +import com.helger.jcodemodel.JVar; + +public class GetModelActionProcessor extends BaseActionProcessor { + + @Override + public void process(ActionInfo actionInfo) { + super.process(actionInfo); + + ActionMethod init = getActionMethod("init"); + ActionMethod query = getActionMethod("query"); + ActionMethod orderBy = getActionMethod("orderBy"); + + IJExpression queryExp = null; + if (query.metaData != null) { + queryExp = direct((String) query.params.get(0).metaData.get("value")); + } + + IJExpression orderByExp = null; + if (orderBy.metaData != null) { + orderByExp = direct((String) orderBy.params.get(0).metaData.get("value")); + } + + if (init.metaData != null) { + ActionMethodParam initParam = init.params.get(0); + Element field = (Element) initParam.metaData.get("field"); + Object holder = actionInfo.metaData.get("holder"); + JVar action = (JVar) actionInfo.metaData.get("action"); + + if (field != null && holder != null && action != null) { + Model modelAnnotation = field.getAnnotation(Model.class); + if (modelAnnotation != null) { + + JMethod getModelMethod = ActionProcessorUtil.getMethodInHolder( + "getGetModelMethod", holder, "com.dspot.declex.model.ModelHolder", field + ); + + if (queryExp==null) + queryExp = FormatsUtils.expressionFromString(modelAnnotation.query()); + + if (orderByExp==null) + orderByExp = FormatsUtils.expressionFromString(modelAnnotation.orderBy()); + + IJExpression contextExpr = ActionProcessorUtil.getMethodInHolder("getContextRef", holder); + if (contextExpr == _this()) { + JDefinedClass generatedClass = ActionProcessorUtil.getMethodInHolder("getGeneratedClass", holder); + contextExpr = generatedClass.staticRef("this"); + } + + JInvocation invoke = invoke(getModelMethod) + .arg(contextExpr) + .arg(queryExp).arg(orderByExp) + .arg(action.invoke("getAfterLoad")); + + addPostBuildBlock(invoke); + + } else { + throw new IllegalStateException("The field " + field + " is not annotated with @Model"); + } + } + } + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/PopulateActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/processor/PopulateActionProcessor.java new file mode 100644 index 00000000..d1fb648e --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/PopulateActionProcessor.java @@ -0,0 +1,55 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import static com.helger.jcodemodel.JExpr.invoke; + +import javax.lang.model.element.Element; + +import com.dspot.declex.api.action.process.ActionInfo; +import com.dspot.declex.api.action.process.ActionMethod; +import com.dspot.declex.api.action.process.ActionMethodParam; +import com.dspot.declex.api.populator.Populator; +import com.helger.jcodemodel.JInvocation; + +public class PopulateActionProcessor extends BaseActionProcessor { + + @Override + public void process(ActionInfo actionInfo) { + super.process(actionInfo); + + ActionMethod init = getActionMethod("init"); + + if (init.metaData != null) { + ActionMethodParam initParam = init.params.get(0); + Element field = (Element) initParam.metaData.get("field"); + + if (field != null) { + + Populator populatorAnnotation = field.getAnnotation(Populator.class); + if (populatorAnnotation != null) { + + JInvocation invoke = invoke("_populate_" + field.getSimpleName().toString()); + addPostBuildBlock(invoke); + + } else { + throw new IllegalStateException("The field " + field + " is not annotated with @Populator"); + } + } + } + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/PutModelActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/processor/PutModelActionProcessor.java new file mode 100644 index 00000000..1c6a5166 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/PutModelActionProcessor.java @@ -0,0 +1,86 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import static com.helger.jcodemodel.JExpr.direct; +import static com.helger.jcodemodel.JExpr.invoke; + +import javax.lang.model.element.Element; + +import com.dspot.declex.api.action.process.ActionInfo; +import com.dspot.declex.api.action.process.ActionMethod; +import com.dspot.declex.api.action.process.ActionMethodParam; +import com.dspot.declex.api.model.Model; +import com.dspot.declex.api.util.FormatsUtils; +import com.helger.jcodemodel.IJExpression; +import com.helger.jcodemodel.JInvocation; +import com.helger.jcodemodel.JMethod; +import com.helger.jcodemodel.JVar; + +public class PutModelActionProcessor extends BaseActionProcessor { + + @Override + public void process(ActionInfo actionInfo) { + super.process(actionInfo); + + ActionMethod init = getActionMethod("init"); + ActionMethod query = getActionMethod("query"); + ActionMethod orderBy = getActionMethod("orderBy"); + + IJExpression queryExp = null; + if (query.metaData != null) { + queryExp = direct((String) query.params.get(0).metaData.get("value")); + } + + IJExpression orderByExp = null; + if (orderBy.metaData != null) { + orderByExp = direct((String) orderBy.params.get(0).metaData.get("value")); + } + + if (init.metaData != null) { + ActionMethodParam initParam = init.params.get(0); + Element field = (Element) initParam.metaData.get("field"); + Object holder = actionInfo.metaData.get("holder"); + JVar action = (JVar) actionInfo.metaData.get("action"); + + if (field != null && holder != null && action != null) { + Model modelAnnotation = field.getAnnotation(Model.class); + if (modelAnnotation != null) { + + JMethod putModelMethod = ActionProcessorUtil.getMethodInHolder( + "getPutModelMethod", holder, "com.dspot.declex.model.ModelHolder", field + ); + + if (queryExp==null) + queryExp = FormatsUtils.expressionFromString(modelAnnotation.query()); + + if (orderByExp==null) + orderByExp = FormatsUtils.expressionFromString(modelAnnotation.orderBy()); + + JInvocation invoke = invoke(putModelMethod) + .arg(queryExp).arg(orderByExp) + .arg(action.invoke("getAfterPut")); + + addPostBuildBlock(invoke); + + } else { + throw new IllegalStateException("The field " + field + " is not annotated with @Model"); + } + } + } + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/processor/RecollectActionProcessor.java b/declex-api/src/com/dspot/declex/api/action/processor/RecollectActionProcessor.java new file mode 100644 index 00000000..7089414b --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/processor/RecollectActionProcessor.java @@ -0,0 +1,58 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.processor; + +import static com.helger.jcodemodel.JExpr.invoke; + +import javax.lang.model.element.Element; + +import com.dspot.declex.api.action.process.ActionInfo; +import com.dspot.declex.api.action.process.ActionMethod; +import com.dspot.declex.api.action.process.ActionMethodParam; +import com.dspot.declex.api.populator.Recollector; +import com.helger.jcodemodel.JInvocation; +import com.helger.jcodemodel.JVar; + +public class RecollectActionProcessor extends BaseActionProcessor { + + @Override + public void process(ActionInfo actionInfo) { + super.process(actionInfo); + + ActionMethod init = getActionMethod("init"); + + if (init.metaData != null) { + ActionMethodParam initParam = init.params.get(0); + Element field = (Element) initParam.metaData.get("field"); + JVar action = (JVar) actionInfo.metaData.get("action"); + + if (field != null && action != null) { + + Recollector recollectorAnnotation = field.getAnnotation(Recollector.class); + if (recollectorAnnotation != null) { + + JInvocation invoke = invoke("_recollect_" + field.getSimpleName().toString()) + .arg(action.invoke("getDone")); + addPostBuildBlock(invoke); + + } else { + throw new IllegalStateException("The field " + field + " is not annotated with @Recollector"); + } + } + } + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/IFireable.java b/declex-api/src/com/dspot/declex/api/action/sequence/IFireable.java new file mode 100644 index 00000000..8c5e7134 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/IFireable.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public interface IFireable { + public void fire(); +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/P1.java b/declex-api/src/com/dspot/declex/api/action/sequence/P1.java new file mode 100644 index 00000000..bdaf7fa3 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/P1.java @@ -0,0 +1,25 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class P1 implements IFireable { + + @Override + public void fire() { + + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/P2.java b/declex-api/src/com/dspot/declex/api/action/sequence/P2.java new file mode 100644 index 00000000..5c1a08c2 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/P2.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class P2 extends P1 { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/P3.java b/declex-api/src/com/dspot/declex/api/action/sequence/P3.java new file mode 100644 index 00000000..299acaa3 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/P3.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class P3 extends P2 { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/P4.java b/declex-api/src/com/dspot/declex/api/action/sequence/P4.java new file mode 100644 index 00000000..d13d8c87 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/P4.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class P4 extends P3 { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/P5.java b/declex-api/src/com/dspot/declex/api/action/sequence/P5.java new file mode 100644 index 00000000..ee88bd5a --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/P5.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class P5 extends P4 { + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/S1.java b/declex-api/src/com/dspot/declex/api/action/sequence/S1.java new file mode 100644 index 00000000..fe417bd6 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/S1.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class S1 implements IFireable { + + @Override + public void fire() { + + } + + public static A with(Object ... objects) { + return null; + } + +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/S2.java b/declex-api/src/com/dspot/declex/api/action/sequence/S2.java new file mode 100644 index 00000000..0aa14556 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/S2.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class S2 extends S1 { +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/S3.java b/declex-api/src/com/dspot/declex/api/action/sequence/S3.java new file mode 100644 index 00000000..f0062c72 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/S3.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class S3 extends S2 { +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/S4.java b/declex-api/src/com/dspot/declex/api/action/sequence/S4.java new file mode 100644 index 00000000..7686b2ea --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/S4.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class S4 extends S3 { +} diff --git a/declex-api/src/com/dspot/declex/api/action/sequence/S5.java b/declex-api/src/com/dspot/declex/api/action/sequence/S5.java new file mode 100644 index 00000000..ce2de8d4 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/action/sequence/S5.java @@ -0,0 +1,19 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.action.sequence; + +public class S5 extends S4 { +} diff --git a/declex-api/src/com/dspot/declex/api/define/Define.java b/declex-api/src/com/dspot/declex/api/define/Define.java new file mode 100644 index 00000000..2c6e0da7 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/define/Define.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.define; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface Define { + String[] value(); +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/Event.java b/declex-api/src/com/dspot/declex/api/eventbus/Event.java new file mode 100644 index 00000000..3f152776 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/Event.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface Event { + String[] value() default ""; +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/LoadOnEvent.java b/declex-api/src/com/dspot/declex/api/eventbus/LoadOnEvent.java new file mode 100644 index 00000000..a15422e2 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/LoadOnEvent.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface LoadOnEvent { + Class value(); + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/PutOnEvent.java b/declex-api/src/com/dspot/declex/api/eventbus/PutOnEvent.java new file mode 100644 index 00000000..c09b8311 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/PutOnEvent.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface PutOnEvent { + Class value(); + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/UpdateOnEvent.java b/declex-api/src/com/dspot/declex/api/eventbus/UpdateOnEvent.java new file mode 100644 index 00000000..9ebe2cf0 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/UpdateOnEvent.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface UpdateOnEvent { + Class value(); + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/UseEventBus.java b/declex-api/src/com/dspot/declex/api/eventbus/UseEventBus.java new file mode 100644 index 00000000..d4d55420 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/UseEventBus.java @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface UseEventBus { + boolean debug() default false; + + boolean custom() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/eventbus/UseEvents.java b/declex-api/src/com/dspot/declex/api/eventbus/UseEvents.java new file mode 100644 index 00000000..face5206 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/eventbus/UseEvents.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.eventbus; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface UseEvents { + boolean custom() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/extension/Extension.java b/declex-api/src/com/dspot/declex/api/extension/Extension.java new file mode 100644 index 00000000..06e773e6 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/extension/Extension.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.extension; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface Extension { + +} diff --git a/declex-api/src/com/dspot/declex/api/localdb/LocalDBModel.java b/declex-api/src/com/dspot/declex/api/localdb/LocalDBModel.java new file mode 100644 index 00000000..ab5eb45a --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/localdb/LocalDBModel.java @@ -0,0 +1,35 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.localdb; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +public @interface LocalDBModel { + String table() default ""; + + String defaultQuery() default ""; + + boolean hasTable() default true; + + boolean ignorePut() default false; + + boolean custom() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/localdb/LocalDBTransaction.java b/declex-api/src/com/dspot/declex/api/localdb/LocalDBTransaction.java new file mode 100644 index 00000000..be6c2cad --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/localdb/LocalDBTransaction.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.localdb; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.METHOD) +public @interface LocalDBTransaction { +} diff --git a/declex-api/src/com/dspot/declex/api/localdb/UseLocalDB.java b/declex-api/src/com/dspot/declex/api/localdb/UseLocalDB.java new file mode 100644 index 00000000..e5556f51 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/localdb/UseLocalDB.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.localdb; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.TYPE) +public @interface UseLocalDB { + +} diff --git a/declex-api/src/com/dspot/declex/api/model/AfterLoad.java b/declex-api/src/com/dspot/declex/api/model/AfterLoad.java new file mode 100644 index 00000000..ae3c9fe7 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/model/AfterLoad.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.model; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.METHOD) +public @interface AfterLoad { +} diff --git a/declex-api/src/com/dspot/declex/api/model/AfterPut.java b/declex-api/src/com/dspot/declex/api/model/AfterPut.java new file mode 100644 index 00000000..db7082de --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/model/AfterPut.java @@ -0,0 +1,26 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.model; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.METHOD) +public @interface AfterPut { +} diff --git a/declex-api/src/com/dspot/declex/api/model/Model.java b/declex-api/src/com/dspot/declex/api/model/Model.java new file mode 100644 index 00000000..fed4f164 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/model/Model.java @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.model; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface Model { + /** + * The query to fetch the @Model + */ + String query() default ""; + + /** + * The orderBy parameter of the fetch + */ + String orderBy() default ""; + + /** + * Determine if this model is going to be loaded asynchronously. By default is false. + */ + boolean async() default false; + + /** + * Determine if this model is going to be put asynchronously. By default is true. + */ + boolean asyncPut() default true; + + /** + * Determines if load this @Model when it is requested, lazily. + * This is permitted only when declared inside another model object (Annotated with @UseModel) + */ + boolean lazy() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/model/UseModel.java b/declex-api/src/com/dspot/declex/api/model/UseModel.java new file mode 100644 index 00000000..c51a576b --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/model/UseModel.java @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.model; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.FIELD}) +public @interface UseModel { + + String defaultQuery() default ""; + + boolean custom() default false; + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/populator/AdapterClass.java b/declex-api/src/com/dspot/declex/api/populator/AdapterClass.java new file mode 100644 index 00000000..eee875bc --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/populator/AdapterClass.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.populator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.FIELD}) +public @interface AdapterClass { + Class value(); +} diff --git a/declex-api/src/com/dspot/declex/api/populator/Populator.java b/declex-api/src/com/dspot/declex/api/populator/Populator.java new file mode 100644 index 00000000..23f98662 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/populator/Populator.java @@ -0,0 +1,39 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.populator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface Populator { + + /** + * A List of Layouts to be inflated by the populator + */ + int[] value() default 0; + + /** + * The custom value is used to indicate in the case of a List that a + * custom adapter is going to be used + */ + boolean custom() default false; + + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/populator/Recollector.java b/declex-api/src/com/dspot/declex/api/populator/Recollector.java new file mode 100644 index 00000000..48a2690e --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/populator/Recollector.java @@ -0,0 +1,28 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.populator; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.CLASS) +@Target(ElementType.FIELD) +public @interface Recollector { + boolean validate() default false; + boolean debug() default false; +} diff --git a/declex-api/src/com/dspot/declex/api/server/SerializeCondition.java b/declex-api/src/com/dspot/declex/api/server/SerializeCondition.java new file mode 100644 index 00000000..f07f3e37 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/server/SerializeCondition.java @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.server; + +public @interface SerializeCondition { + String value(); +} diff --git a/declex-api/src/com/dspot/declex/api/server/ServerModel.java b/declex-api/src/com/dspot/declex/api/server/ServerModel.java new file mode 100644 index 00000000..4e401b75 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/server/ServerModel.java @@ -0,0 +1,53 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.server; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import com.dspot.declex.api.server.ServerRequest.RequestType; + +@Retention(RetentionPolicy.CLASS) +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +public @interface ServerModel { + String baseUrl() default ""; + + String get() default ""; + String post() default ""; + + String[] getHeaders() default ""; + String[] postHeaders() default ""; + + RequestType postType() default RequestType.Body; + String[] postFields() default ""; + + String model() default ""; + Class modelClass() default Object.class; + + boolean mock() default false; + String mockResult() default ""; + + boolean avoidExceptions() default true; + + String defaultQuery() default ""; + + boolean custom() default false; + + ServerRequest[] load() default @ServerRequest(action="NONE"); + ServerRequest[] put() default @ServerRequest(action="NONE"); +} diff --git a/declex-api/src/com/dspot/declex/api/server/ServerRequest.java b/declex-api/src/com/dspot/declex/api/server/ServerRequest.java new file mode 100644 index 00000000..f927f304 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/server/ServerRequest.java @@ -0,0 +1,37 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.server; + +public @interface ServerRequest { + String name() default ""; + + RequestMethod method() default RequestMethod.Default; + RequestType type() default RequestType.Body; + + String action(); + String[] headers() default ""; + + String[] fields() default ""; + + String model() default ""; + Class modelClass() default Object.class; + + boolean mock() default false; + String mockResult() default ""; + + public enum RequestMethod {Default, Delete, Get, Head, Post, Put, Patch} + public enum RequestType {Body, Fields} +} diff --git a/declex-api/src/com/dspot/declex/api/util/CastUtility.java b/declex-api/src/com/dspot/declex/api/util/CastUtility.java new file mode 100644 index 00000000..b8ff541a --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/util/CastUtility.java @@ -0,0 +1,219 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.util; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import com.dspot.declex.api.util.annotation.CopyIgnore; +import com.dspot.declex.api.util.annotation.CopyName; + +public class CastUtility { + + public static Map getFields(Object object) { + //Use fieldsMap to return the fields sorted alphabetically + Map fieldsMap = new TreeMap(new Comparator() { + + @Override + public int compare(EField lhs, EField rhs) { + return lhs.getName().compareTo(rhs.getName()); + } + }); + + Class cls = object.getClass(); + while (!cls.equals(Object.class)) + try { + Field[] fields = cls.getDeclaredFields(); + for (Field field : fields) { + //Ignore No-Copiable Modifiers + int fieldMofiers = field.getModifiers(); + if (Modifier.isTransient(fieldMofiers) || + Modifier.isStatic(fieldMofiers) || + Modifier.isFinal(fieldMofiers) || + field.getAnnotation(CopyIgnore.class) != null) continue; + + field.setAccessible(true); + fieldsMap.put(new EField(field), field.get(object)); + } + + cls = cls.getSuperclass(); + } catch (IllegalAccessException e) { + } catch (IllegalArgumentException e) { + } + + return fieldsMap; + + } + + public static void copy(String fieldName, Object from, List to) { + + Iterable iterableFrom = null; + if (from.getClass().isArray()) { + List newList = new ArrayList<>(Array.getLength(from)); + for (int i = 0; i < Array.getLength(from); i++) { + newList.add(Array.get(from, i)); + } + iterableFrom = newList; + } else if (from instanceof Iterable) { + iterableFrom = ((Iterable) from); + } + + Iterator fromIterator = iterableFrom != null ? iterableFrom.iterator() : null; + if (to.size() == 0) return; + + Map toFields = getFields(to.get(0)); + Iterator toFieldsIterator = toFields.keySet().iterator(); + + iter: while (toFieldsIterator.hasNext()) { + EField field = toFieldsIterator.next(); + if (field.name.equals(fieldName)) { + + for (Object toObject : to) { + Object fromObject = from; + + if (fromIterator != null) { + if (fromIterator.hasNext()) { + fromObject = fromIterator.next(); + } else break iter; + } + + try { + field.field.set(toObject, fromObject); + } catch (IllegalAccessException + | IllegalArgumentException e) { + e.printStackTrace(); + } + } + + break iter; + } + } + } + + public static void copy(Object from, Object to, String ... toIgnore) { + Map fromFields = getFields(from); + Map toFields = getFields(to); + + Iterator fromFieldsIterator = fromFields.keySet().iterator(); + Iterator toFieldsIterator = toFields.keySet().iterator(); + + EField fromField = fromFieldsIterator.next(); + EField toField = toFieldsIterator.next(); + + List toIgnoreList = toIgnore == null ? new ArrayList<>() : new ArrayList(Arrays.asList(toIgnore)); + + while (true) { + + while (fromField.getName().compareTo(toField.getName()) < 0) { + if (!fromFieldsIterator.hasNext()) return; + + fromField = fromFieldsIterator.next(); + } + + while (fromField.getName().compareTo(toField.getName()) > 0) { + if (!toFieldsIterator.hasNext()) return; + + toField = toFieldsIterator.next(); + } + + if (fromField.getName().equals(toField.getName())) { + + if (!toIgnoreList.contains(toField.getName())) { + if (fromField.getType().equals(toField.getType())) { + try { + toField.set(to, fromFields.get(fromField)); + } catch (IllegalAccessException | IllegalArgumentException e) { + } + } else { + //Handle field castings + try { + //Handling Primitive types + Class toFieldClass = toField.getType(); + if (toFieldClass.isPrimitive()) { + if (toField.getType().equals(short.class)) toFieldClass = Short.class; + else if (toField.getType().equals(byte.class)) toFieldClass = Byte.class; + else if (toField.getType().equals(char.class)) toFieldClass = Character.class; + else if (toField.getType().equals(int.class)) toFieldClass = Integer.class; + else if (toField.getType().equals(byte.class)) toFieldClass = Byte.class; + else if (toField.getType().equals(float.class)) toFieldClass = Float.class; + else if (toField.getType().equals(double.class)) toFieldClass = Double.class; + } + + Method valueOf = toFieldClass.getMethod("valueOf", String.class); + + if (valueOf != null) { + Object valueOfFrom = valueOf.invoke(null, fromFields.get(fromField).toString()); + toField.set(to, valueOfFrom); + } + + } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + } + + + } + } + + if (!fromFieldsIterator.hasNext() || !toFieldsIterator.hasNext()) return; + fromField = fromFieldsIterator.next(); + toField = toFieldsIterator.next(); + } + } + + } + + private static class EField { + private Field field; + private String name; + + public EField(Field field) { + this.field = field; + + CopyName copyName = field.getAnnotation(CopyName.class); + if (copyName != null) { + this.name = copyName.value(); + } else { + name = field.getName(); + } + } + + public String getName() { + return this.name; + } + + public Class getType() { + return field.getType(); + } + + public void set(Object object, Object value) throws IllegalAccessException, IllegalArgumentException { + field.set(object, value); + } + + @Override + public String toString() { + return this.name; + } + } +} diff --git a/declex-api/src/com/dspot/declex/api/util/FormatsUtils.java b/declex-api/src/com/dspot/declex/api/util/FormatsUtils.java new file mode 100644 index 00000000..65c981f3 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/util/FormatsUtils.java @@ -0,0 +1,88 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.util; + +import static com.helger.jcodemodel.JExpr.direct; +import static com.helger.jcodemodel.JExpr.lit; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.helger.jcodemodel.IJExpression; + +public class FormatsUtils { + //This term (?!(?:\\s*\"[^\"]+\"\\s*:)), is to exclude JSON structures + public static final String FORMAT_SYNTAX_REGX = "\\{(?!(?:\\s*\"[^\"]+\"\\s*:))([^\\}\\{]+)(\\{(\\d+)\\})*\\}"; + + public static IJExpression expressionFromString(String value) { + Matcher matcher = Pattern.compile(FORMAT_SYNTAX_REGX).matcher(value); + + IJExpression expression = null; + int prev = 0; + while (matcher.find()) { + String match = matcher.group(1); + if (matcher.groupCount() == 3 && matcher.group(3) != null && !matcher.group(3).equals("")) { + match = match + ".split(\"\\\\s*[,;:]\\\\s*\")[" + matcher.group(3) + "]"; + } + + if (expression == null) { + if (prev != matcher.start()) { + expression = lit(value.substring(prev, matcher.start())) + .plus(direct(match).plus(lit(""))); + } else { + expression = direct(match).plus(lit("")); + } + } else { + if (prev != matcher.start()) { + expression = expression.plus(lit(value.substring(prev, matcher.start()))); + } + + expression = expression.plus(direct(match)).plus(lit("")); + } + + prev = matcher.end(); + } + + if (expression != null) { + if (prev != value.length()) { + expression = expression.plus(lit(value.substring(prev))); + } + + return expression; + } + + return lit(value); + } + + public static String fieldToGetter(String name) { + Matcher matcher = Pattern.compile("_(\\w)").matcher(name); + while (matcher.find()) { + name = name.replaceFirst(matcher.group(0), matcher.group(1).toUpperCase()); + } + + return "get" + name.substring(0, 1).toUpperCase() + name.substring(1); + } + + public static String fieldToSetter(String name) { + Matcher matcher = Pattern.compile("_(\\w)").matcher(name); + while (matcher.find()) { + name = name.replaceFirst(matcher.group(0), matcher.group(1).toUpperCase()); + } + + return "set" + name.substring(0, 1).toUpperCase() + name.substring(1); + } + +} diff --git a/declex-api/src/com/dspot/declex/api/util/annotation/CopyIgnore.java b/declex-api/src/com/dspot/declex/api/util/annotation/CopyIgnore.java new file mode 100644 index 00000000..0f583c91 --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/util/annotation/CopyIgnore.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.util.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface CopyIgnore { + +} diff --git a/declex-api/src/com/dspot/declex/api/util/annotation/CopyName.java b/declex-api/src/com/dspot/declex/api/util/annotation/CopyName.java new file mode 100644 index 00000000..1824731f --- /dev/null +++ b/declex-api/src/com/dspot/declex/api/util/annotation/CopyName.java @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex.api.util.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface CopyName { + String value(); +} diff --git a/declex/.classpath b/declex/.classpath new file mode 100644 index 00000000..dadc0fca --- /dev/null +++ b/declex/.classpath @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/declex/.gitignore b/declex/.gitignore new file mode 100644 index 00000000..d853befe --- /dev/null +++ b/declex/.gitignore @@ -0,0 +1,3 @@ +/bin +/.settings +/target/ diff --git a/declex/.project b/declex/.project new file mode 100644 index 00000000..3737c5c3 --- /dev/null +++ b/declex/.project @@ -0,0 +1,40 @@ + + + declex + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + + + androidannotations + 2 + WORKSPACE_LOC/Dependencies/androidannotations/AndroidAnnotations/androidannotations-core/androidannotations/src/main/java + + + androidannotations-api + 2 + C:/Dropbox/Android/SMBuilder/Dependencies/androidannotations/AndroidAnnotations/androidannotations-api/src/main/java + + + evo-inflector + 2 + WORKSPACE_LOC/Dependencies/evo-inflector/src/main/java + + + diff --git a/declex/build.xml b/declex/build.xml new file mode 100644 index 00000000..5f053e96 --- /dev/null +++ b/declex/build.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/declex/libs/freemarker.jar b/declex/libs/freemarker.jar new file mode 100644 index 00000000..c7301a06 Binary files /dev/null and b/declex/libs/freemarker.jar differ diff --git a/declex/libs/jcodemodel-2.8.0.jar b/declex/libs/jcodemodel-2.8.0.jar new file mode 100644 index 00000000..0a0b21f9 Binary files /dev/null and b/declex/libs/jcodemodel-2.8.0.jar differ diff --git a/declex/pom.xml b/declex/pom.xml new file mode 100644 index 00000000..34984451 --- /dev/null +++ b/declex/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + + com.dspot + declex + 1.0 + DecleX + DecleX - The ultimate framework for Android Development + + + src + + + resources + + + src + + **/*.ftl.java + + + + + + + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + **/*.ftl.java + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + verify + + jar-no-fork + + + + + + + + + DSpot Sp. z o.o + http://www.dspot.com.pl + + + + + bintray-declex + https://api.bintray.com/maven/dspot/declex/declex/;publish=1 + + + + + + com.helger + jcodemodel + 2.8.0 + + + + com.dspot + declex-api + ${project.version} + + + + org.freemarker + freemarker + 2.3.25-incubating + + + com.sun + tools + 1.6 + system + ${env.JAVA_HOME}/lib/tools.jar + + + \ No newline at end of file diff --git a/declex/resources/META-INF/services/javax.annotation.processing.Processor b/declex/resources/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 00000000..46c7b10c --- /dev/null +++ b/declex/resources/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1 @@ +com.dspot.declex.DeclexProcessor \ No newline at end of file diff --git a/declex/resources/declex.properties b/declex/resources/declex.properties new file mode 100644 index 00000000..cbd77135 --- /dev/null +++ b/declex/resources/declex.properties @@ -0,0 +1,18 @@ +#Mon, 07 Nov 2016 04:43:05 +0100 +# +# Copyright (C) 2010-2015 eBusiness Information, Excilys Group +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed To in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# + +version=1.0 diff --git a/declex/src/com/dspot/declex/DeclexCorePlugin.java b/declex/src/com/dspot/declex/DeclexCorePlugin.java new file mode 100644 index 00000000..068e8912 --- /dev/null +++ b/declex/src/com/dspot/declex/DeclexCorePlugin.java @@ -0,0 +1,348 @@ +/** + * Copyright (C) 2016 DSpot Sp. z o.o + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.dspot.declex; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import org.androidannotations.AndroidAnnotationsEnvironment; +import org.androidannotations.Option; +import org.androidannotations.handler.AnnotationHandler; +import org.androidannotations.internal.core.handler.AfterExtrasHandler; +import org.androidannotations.internal.core.handler.AfterPreferencesHandler; +import org.androidannotations.internal.core.handler.AfterTextChangeHandler; +import org.androidannotations.internal.core.handler.AnimationResHandler; +import org.androidannotations.internal.core.handler.AppHandler; +import org.androidannotations.internal.core.handler.BackgroundHandler; +import org.androidannotations.internal.core.handler.BeanHandler; +import org.androidannotations.internal.core.handler.BeforeTextChangeHandler; +import org.androidannotations.internal.core.handler.ColorResHandler; +import org.androidannotations.internal.core.handler.ColorStateListResHandler; +import org.androidannotations.internal.core.handler.CustomTitleHandler; +import org.androidannotations.internal.core.handler.DefaultResHandler; +import org.androidannotations.internal.core.handler.DrawableResHandler; +import org.androidannotations.internal.core.handler.EApplicationHandler; +import org.androidannotations.internal.core.handler.EBeanHandler; +import org.androidannotations.internal.core.handler.EIntentServiceHandler; +import org.androidannotations.internal.core.handler.EProviderHandler; +import org.androidannotations.internal.core.handler.EReceiverHandler; +import org.androidannotations.internal.core.handler.EServiceHandler; +import org.androidannotations.internal.core.handler.EViewGroupHandler; +import org.androidannotations.internal.core.handler.EViewHandler; +import org.androidannotations.internal.core.handler.FragmentByIdHandler; +import org.androidannotations.internal.core.handler.FragmentByTagHandler; +import org.androidannotations.internal.core.handler.FromHtmlHandler; +import org.androidannotations.internal.core.handler.FullscreenHandler; +import org.androidannotations.internal.core.handler.HierarchyViewerSupportHandler; +import org.androidannotations.internal.core.handler.HtmlResHandler; +import org.androidannotations.internal.core.handler.HttpsClientHandler; +import org.androidannotations.internal.core.handler.IgnoreWhenHandler; +import org.androidannotations.internal.core.handler.InjectMenuHandler; +import org.androidannotations.internal.core.handler.InstanceStateHandler; +import org.androidannotations.internal.core.handler.KeyDownHandler; +import org.androidannotations.internal.core.handler.KeyLongPressHandler; +import org.androidannotations.internal.core.handler.KeyMultipleHandler; +import org.androidannotations.internal.core.handler.KeyUpHandler; +import org.androidannotations.internal.core.handler.NonConfigurationInstanceHandler; +import org.androidannotations.internal.core.handler.OnActivityResultHandler; +import org.androidannotations.internal.core.handler.OptionsItemHandler; +import org.androidannotations.internal.core.handler.OptionsMenuHandler; +import org.androidannotations.internal.core.handler.OptionsMenuItemHandler; +import org.androidannotations.internal.core.handler.PageScrollStateChangedHandler; +import org.androidannotations.internal.core.handler.PageScrolledHandler; +import org.androidannotations.internal.core.handler.PageSelectedHandler; +import org.androidannotations.internal.core.handler.PrefHandler; +import org.androidannotations.internal.core.handler.PreferenceByKeyHandler; +import org.androidannotations.internal.core.handler.PreferenceChangeHandler; +import org.androidannotations.internal.core.handler.PreferenceClickHandler; +import org.androidannotations.internal.core.handler.PreferenceHeadersHandler; +import org.androidannotations.internal.core.handler.PreferenceScreenHandler; +import org.androidannotations.internal.core.handler.ReceiverActionHandler; +import org.androidannotations.internal.core.handler.ReceiverHandler; +import org.androidannotations.internal.core.handler.RootContextHandler; +import org.androidannotations.internal.core.handler.SeekBarProgressChangeHandler; +import org.androidannotations.internal.core.handler.SeekBarTouchStartHandler; +import org.androidannotations.internal.core.handler.SeekBarTouchStopHandler; +import org.androidannotations.internal.core.handler.ServiceActionHandler; +import org.androidannotations.internal.core.handler.SharedPrefHandler; +import org.androidannotations.internal.core.handler.SupposeBackgroundHandler; +import org.androidannotations.internal.core.handler.SupposeThreadHandler; +import org.androidannotations.internal.core.handler.SupposeUiThreadHandler; +import org.androidannotations.internal.core.handler.SystemServiceHandler; +import org.androidannotations.internal.core.handler.TextChangeHandler; +import org.androidannotations.internal.core.handler.TouchHandler; +import org.androidannotations.internal.core.handler.TraceHandler; +import org.androidannotations.internal.core.handler.TransactionalHandler; +import org.androidannotations.internal.core.handler.UiThreadHandler; +import org.androidannotations.internal.core.handler.ViewByIdHandler; +import org.androidannotations.internal.core.handler.ViewsByIdHandler; +import org.androidannotations.internal.core.handler.WakeLockHandler; +import org.androidannotations.internal.core.handler.WindowFeatureHandler; +import org.androidannotations.internal.core.model.AndroidRes; +import org.androidannotations.plugin.AndroidAnnotationsPlugin; + +import com.dspot.declex.action.ActionForHandler; +import com.dspot.declex.action.ActionHandler; +import com.dspot.declex.action.EActivityActionHandler; +import com.dspot.declex.action.EFragmentActionHandler; +import com.dspot.declex.action.EventsActionHandler; +import com.dspot.declex.action.android.AlertDialogActionHandler; +import com.dspot.declex.action.android.ProgressDialogActionHandler; +import com.dspot.declex.action.android.ToastActionHandler; +import com.dspot.declex.action.model.ModelsActionHandler; +import com.dspot.declex.action.sequence.ParallelActionHandler; +import com.dspot.declex.action.sequence.SequenceActionHandler; +import com.dspot.declex.define.DefineHandler; +import com.dspot.declex.eventbus.EventHandler; +import com.dspot.declex.eventbus.UseEventBusHandler; +import com.dspot.declex.eventbus.UseEventsHandler; +import com.dspot.declex.eventbus.oneventhandler.LoadOnEventHandler; +import com.dspot.declex.eventbus.oneventhandler.PutOnActionHandler; +import com.dspot.declex.eventbus.oneventhandler.PutOnEventHandler; +import com.dspot.declex.eventbus.oneventhandler.UpdateOnEventHandler; +import com.dspot.declex.localdb.LocalDBModelHandler; +import com.dspot.declex.localdb.LocalDBTransactionHandler; +import com.dspot.declex.localdb.UseLocalDBHandler; +import com.dspot.declex.model.AfterLoadHandler; +import com.dspot.declex.model.AfterPutHandler; +import com.dspot.declex.model.ModelHandler; +import com.dspot.declex.model.UseModelHandler; +import com.dspot.declex.override.handler.AfterInjectHandler; +import com.dspot.declex.override.handler.AfterViewsHandler; +import com.dspot.declex.override.handler.CheckedChangeHandler; +import com.dspot.declex.override.handler.ClickHandler; +import com.dspot.declex.override.handler.EActivityHandler; +import com.dspot.declex.override.handler.EFragmentHandler; +import com.dspot.declex.override.handler.EditorActionHandler; +import com.dspot.declex.override.handler.ExtraHandler; +import com.dspot.declex.override.handler.FocusChangeHandler; +import com.dspot.declex.override.handler.FragmentArgHandler; +import com.dspot.declex.override.handler.ItemClickHandler; +import com.dspot.declex.override.handler.ItemLongClickHandler; +import com.dspot.declex.override.handler.ItemSelectHandler; +import com.dspot.declex.override.handler.LongClickHandler; +import com.dspot.declex.plugin.JClassPlugin; +import com.dspot.declex.populator.AdapterClassHandler; +import com.dspot.declex.populator.PopulatorHandler; +import com.dspot.declex.populator.RecollectorHandler; +import com.dspot.declex.server.ServerModelHandler; +import com.dspot.declex.util.SharedRecords; + +public class DeclexCorePlugin extends AndroidAnnotationsPlugin { + + private static final String NAME = "DecleX"; + + public DeclexCorePlugin() { + SharedRecords.reset(); + } + + @Override + public String getName() { + return NAME; + } + + @Override + public List