Last active
December 19, 2018 19:30
-
-
Save jesusjavierdediego/f26845d244269ba854808e1b2d72d61e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@throws(classOf[ReadDBFeaturesException]) | |
def getRequirementFeaturesFromDBByProject(project: String): Option[DataFrame] ={ | |
var result: Option[DataFrame] = None | |
try{ | |
val storedRFsDF = spark | |
.sqlContext | |
.read | |
.format("com.microsoft.azure.cosmosdb.spark") | |
.cosmosDB(featuresStorageMap) | |
.toDF() | |
result = Some(storedRFsDF.filter($"project" === project)) | |
}catch{ | |
case(e: Exception) => { | |
logger.error(s"Error reading from database. reason: ${e}") | |
throw new ReadDBFeaturesException(s"Error reading from database. reason: ${e}") | |
} | |
} | |
result | |
} | |
@throws(classOf[ReadDBFeaturesException]) | |
def getRequirementFeatureFromDBByID(feature_id: String): RequirementFeaturePersistence = { | |
try{ | |
val fId: Int = feature_id.toInt | |
val rfp: RequirementFeaturePersistence = this.datastore | |
.createQuery(classOf[RequirementFeaturePersistence]) | |
.filter("feature_id =" , feature_id) | |
.get() | |
rfp | |
}catch{ | |
case e: Exception => throw new ReadDBFeaturesException(s"Error getting RFP from DB. Reason: ${e}") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment