Skip to content
Permalink
Browse files

query result on blocking request added.

  • Loading branch information...
s4kibs4mi committed May 1, 2017
1 parent a9fc81d commit b57e328eab42f4d6b35273bd8f6ffc28a6d092fd
@@ -12,7 +12,6 @@
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="useAutoImport" value="true" />
</GradleProjectSettings>
</option>
</component>
@@ -10,11 +10,11 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.6" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.7" level="project" />
<orderEntry type="library" name="Gradle: com.eclipsesource.minimal-json:minimal-json:0.9.4" level="project" />
<orderEntry type="library" name="Gradle: org.xerial:sqlite-jdbc:3.14.2.1" level="project" />
<orderEntry type="library" name="Gradle: org.sqldroid:sqldroid:1.0.3" level="project" />
<orderEntry type="library" name="Gradle: com.eclipsesource.minimal-json:minimal-json:0.9.4" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-runtime:1.0.6" level="project" />
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.0.6" level="project" />
</component>
</module>
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-3.1-all.zip
@@ -71,8 +71,8 @@ class PultusORM {
* Method to save data
* @param clazz Class object which data want to add
*/
fun save(clazz: Any) {
PultusORMQuery(connection!!).save(clazz)
fun save(clazz: Any): Boolean {
return PultusORMQuery(connection!!).save(clazz)
}

/**
@@ -89,8 +89,8 @@ class PultusORM {
* @param clazz value of which class going to update
* @param updater holds update condition and values
*/
fun update(clazz: Any, updater: PultusORMUpdater) {
PultusORMQuery(connection!!).update(clazz, updater)
fun update(clazz: Any, updater: PultusORMUpdater): Boolean {
return PultusORMQuery(connection!!).update(clazz, updater)
}

/**
@@ -103,17 +103,6 @@ class PultusORM {
PultusORMQuery(connection!!).update(clazz, updater, callback)
}

/**
* Method to get data of specific clazz
* It's deprecated use find method instead
* @param clazz which class of data will provide
* @return MutableList of type Any
*/
@Deprecated("use find instead of get")
fun get(clazz: Any): MutableList<Any> {
return PultusORMQuery(connection!!).get(clazz)
}

/**
* Method to get data of specific clazz
* @param clazz which class of data will provide
@@ -123,18 +112,6 @@ class PultusORM {
return PultusORMQuery(connection!!).get(clazz)
}

/**
* Method to get data of specific clazz based of provided condition
* It's deprecated use find method instead
* @param clazz which class of data will provide
* @param condition condition will be used to get data
* @return MutableList of type Any
*/
@Deprecated("use find instead of get")
fun get(clazz: Any, condition: PultusORMCondition): MutableList<Any> {
return PultusORMQuery(connection!!).get(clazz, condition)
}

/**
* Method to get data of specific clazz based of provided condition
* @param clazz which class of data will provide
@@ -149,17 +126,17 @@ class PultusORM {
* Method to delete data of specific clazz
* @param clazz which type of data will be deleted
*/
fun delete(clazz: Any) {
PultusORMQuery(connection!!).delete(clazz)
fun delete(clazz: Any): Boolean {
return PultusORMQuery(connection!!).delete(clazz)
}

/**
* Method to delete data of specific clazz based on condition
* @param clazz which type of data will be deleted
* @param condition will be used to delete data
*/
fun delete(clazz: Any, condition: PultusORMCondition) {
PultusORMQuery(connection!!).delete(clazz, condition)
fun delete(clazz: Any, condition: PultusORMCondition): Boolean {
return PultusORMQuery(connection!!).delete(clazz, condition)
}

/**
@@ -185,8 +162,8 @@ class PultusORM {
* Method to drop table
* @param clazz which type of table will be deleted
*/
fun drop(clazz: Any) {
PultusORMQuery(connection!!).drop(clazz)
fun drop(clazz: Any): Boolean {
return PultusORMQuery(connection!!).drop(clazz)
}

/**
@@ -50,15 +50,17 @@ class PultusORMQuery(connection: Connection) {
* Method to save value
* @param clazz
*/
fun save(clazz: Any) {
fun save(clazz: Any): Boolean {
try {
createTable(clazz)

statement.execute(Builder().insert(clazz))
log(this.javaClass.simpleName, "Inserted into ${clazz.javaClass.simpleName} - Succeed")
return true
} catch (exception: Exception) {
log(this.javaClass.simpleName, "Inserted into ${clazz.javaClass.simpleName} - Failed <${exception.message}>")
}
return false
}

/**
@@ -124,7 +126,7 @@ class PultusORMQuery(connection: Connection) {
resultList.add(jsonAsObject(clazz, it))
}
} catch (exception: Exception) {
throwback("Malformed query <${query.toString()}>. Caused by ${exception.message}")
throwback("Malformed query <$query>. Caused by ${exception.message}")
}
return resultList
}
@@ -177,14 +179,16 @@ class PultusORMQuery(connection: Connection) {
* @param clazz
* @param updateQuery update parameters
*/
fun update(clazz: Any, updateQuery: PultusORMUpdater) {
fun update(clazz: Any, updateQuery: PultusORMUpdater): Boolean {
createTable(clazz)

try {
statement.execute(Builder().update(clazz, updateQuery))
return true
} catch (exception: Exception) {
throwback("Malformed update query.")
}
return false
}

/**
@@ -211,31 +215,35 @@ class PultusORMQuery(connection: Connection) {
* Method to delete value
* @param clazz
*/
fun delete(clazz: Any) {
fun delete(clazz: Any): Boolean {
createTable(clazz)

try {
statement.execute(Builder().delete(clazz))
log(this.javaClass.simpleName, "Table ${parseClassName(clazz)} dropped - Succeed")
log(this.javaClass.simpleName, "Table ${parseClassName(clazz)} data deleted - Succeed")
return true
} catch (exception: Exception) {
log(this.javaClass.simpleName, "Table ${parseClassName(clazz)} dropped - Failed <${exception.message}>")
log(this.javaClass.simpleName, "Table ${parseClassName(clazz)} data deleted - Failed <${exception.message}>")
}
return false
}

/**
* Method to delete value based on condition
* @param clazz
* @param condition condition to update value
*/
fun delete(clazz: Any, condition: PultusORMCondition) {
fun delete(clazz: Any, condition: PultusORMCondition): Boolean {
createTable(clazz)

try {
statement.execute(Builder().delete(clazz, condition))
log(this.javaClass.simpleName, "Table ${clazz.javaClass.simpleName} delete - Succeed")
return true
} catch (exception: Exception) {
log(this.javaClass.simpleName, "Table ${clazz.javaClass.simpleName} delete - Failed <${exception.message}>")
}
return false
}

/**
@@ -281,13 +289,15 @@ class PultusORMQuery(connection: Connection) {
* Method to delete table
* @param clazz
*/
fun drop(clazz: Any) {
fun drop(clazz: Any): Boolean {
try {
if (isTableExists(clazz.javaClass.simpleName))
statement.execute(Builder().drop(clazz))
return true
} catch (exception: Exception) {
throwback("Malformed drop query.")
}
return false
}

/**
@@ -31,7 +31,8 @@ class PultusORMTest : Callback {
student.department = "CSE"
student.cgpa = 2.3

pultusORM.save(student)
val result = pultusORM.save(student)
Assert.assertTrue(result)
}

@Test
@@ -95,7 +96,8 @@ class PultusORMTest : Callback {

@Test
fun deleteValue() {
pultusORM.delete(Student())
val result = pultusORM.delete(Student())
Assert.assertTrue(result)
}

@Test

0 comments on commit b57e328

Please sign in to comment.
You can’t perform that action at this time.