com.fasterxml.jackson.annotation.JsonIgnoreProperties Scala Examples
The following examples show how to use com.fasterxml.jackson.annotation.JsonIgnoreProperties.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: FileField.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.sources import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import org.squeryl.PrimitiveTypeMode._ import org.squeryl.annotations.Column import org.squeryl.{KeyedEntity, Query} object FileField { def getByOwner(id: String): Query[FileField] = { from(AppDB.fileSchemaTable) (sc => where(sc.owner === id) select sc ) } def deleteByName(name: String, owner: String): Int = { AppDB.fileSchemaTable.deleteWhere(m => (m.fieldName === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.fileSchemaTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class FileField( owner:String, @Column("field_name") fieldName: String, @Column("field_type") fieldType: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, fieldName) def insert(): FileField = AppDB.fileSchemaTable.insert(this) }
Example 2
Source File: DruidMetric.scala From gimel with Apache License 2.0 | 5 votes |
package com.paypal.gimel.druid.model import com.fasterxml.jackson.annotation.JsonIgnoreProperties import io.druid.query.aggregation.{AggregatorFactory, CountAggregatorFactory, LongSumAggregatorFactory} import io.druid.query.aggregation.hyperloglog.HyperUniquesAggregatorFactory import org.json4s._ import org.json4s.FieldSerializer._ import com.paypal.gimel.druid.model.DruidMetric.{MetricFieldNames, MetricTypes} def getAggregator: AggregatorFactory = { metricsType match { case MetricTypes.LONG_SUM => new LongSumAggregatorFactory(name, fieldName) case MetricTypes.COUNT => new CountAggregatorFactory(name) case MetricTypes.HYPER_UNIQUE => new HyperUniquesAggregatorFactory(name, fieldName) case otherType: String => throw new Exception(s"Metric Type: $otherType is not supported.") } } } object DruidMetric { def getDefaultMetric: DruidMetric = { DruidMetric(MetricTypes.COUNT, null, MetricTypes.COUNT) } object MetricFieldNames { val TYPE = "type" val FIELD_NAME = "field_name" val NAME = "name" } object MetricTypes { val LONG_SUM = "longSum" val COUNT = "count" val HYPER_UNIQUE = "hyperUnique" } // Deserializer for Druid Metric. // Ignore fieldName if does not exists. // Rename metricsType -> type, fieldName -> field_name, name -> name val drudMetricSerializer: FieldSerializer[DruidMetric] = FieldSerializer[DruidMetric] ( ignore("fieldName") orElse renameTo("metricsType", MetricFieldNames.TYPE) orElse renameTo("fieldName", MetricFieldNames.FIELD_NAME) orElse renameTo("name", MetricFieldNames.NAME), renameFrom(MetricFieldNames.TYPE, "metricsType") orElse renameFrom(MetricFieldNames.FIELD_NAME, "fieldName") orElse renameFrom(MetricFieldNames.NAME, "name") ) }
Example 3
Source File: SparkPlanInfo.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.execution import com.fasterxml.jackson.annotation.JsonIgnoreProperties import org.apache.spark.annotation.DeveloperApi import org.apache.spark.sql.execution.exchange.ReusedExchangeExec import org.apache.spark.sql.execution.metric.SQLMetricInfo @DeveloperApi @JsonIgnoreProperties(Array("metadata")) // The metadata field was removed in Spark 2.3. class SparkPlanInfo( val nodeName: String, val simpleString: String, val children: Seq[SparkPlanInfo], val metrics: Seq[SQLMetricInfo]) { override def hashCode(): Int = { // hashCode of simpleString should be good enough to distinguish the plans from each other // within a plan simpleString.hashCode } override def equals(other: Any): Boolean = other match { case o: SparkPlanInfo => nodeName == o.nodeName && simpleString == o.simpleString && children == o.children case _ => false } } private[execution] object SparkPlanInfo { def fromSparkPlan(plan: SparkPlan): SparkPlanInfo = { val children = plan match { case ReusedExchangeExec(_, child) => child :: Nil case _ => plan.children ++ plan.subqueries } val metrics = plan.metrics.toSeq.map { case (key, metric) => new SQLMetricInfo(metric.name.getOrElse(key), metric.id, metric.metricType) } new SparkPlanInfo(plan.nodeName, plan.simpleString, children.map(fromSparkPlan), metrics) } }
Example 4
Source File: FileField.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.sources import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import org.squeryl.PrimitiveTypeMode._ import org.squeryl.annotations.Column import org.squeryl.{KeyedEntity, Query} object FileField { def getByOwner(id: String): Query[FileField] = { from(AppDB.fileSchemaTable) (sc => where(sc.owner === id) select sc ) } def deleteByName(name: String, owner: String): Int = { AppDB.fileSchemaTable.deleteWhere(m => (m.fieldName === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.fileSchemaTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class FileField( owner:String, @Column("field_name") fieldName: String, @Column("field_type") fieldType: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, fieldName) def insert(): FileField = AppDB.fileSchemaTable.insert(this) }
Example 5
Source File: TargetToChecks.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.targets import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import org.squeryl.annotations.Column object TargetToChecks { def applyWithoutOwner(check: String): TargetToChecks = { TargetToChecks(check) } def unapplyWithoutOwner(ttc: TargetToChecks): Option[String] = { Option(ttc.checkId) } def deleteByCheck(check: String): Int = { AppDB.targetToChecksTable.deleteWhere(m => m.checkId === check) } def deleteById(check: String, owner: String): Int = { AppDB.targetToChecksTable.deleteWhere(m => (m.checkId === check) and (m.targetId === owner)) } def updateChecks(prev: String, curr: String): Int = { update(AppDB.targetToChecksTable)(ttc => where(ttc.checkId === prev) set(ttc.checkId := curr) ) } def getAvailableTargetsForCheck(check: String): Set[String] = { from(AppDB.targetTable)(tar => where(tar.targetType === "SYSTEM" and (tar.id notIn from(AppDB.targetToChecksTable)(ttc => where(ttc.checkId === check) select ttc.targetId))) select tar.id).toSet } def addTargetForCheck(check: String, list: Set[String]): Unit = { val ttcList: Set[TargetToChecks] = list map (x => TargetToChecks(check, x)) AppDB.targetToChecksTable.insert(ttcList) } } @JsonIgnoreProperties(Array("targetId")) case class TargetToChecks( @Column("check_id") checkId: String, @Column("target_id") targetId: String = "" ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (checkId, targetId) def insert: TargetToChecks = AppDB.targetToChecksTable.insert(this) }
Example 6
Source File: Mail.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.targets import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ object Mail { def applyWithoutOwner(mail: String): Mail = { Mail(mail) } def unapplyWithoutOwner(mail: Mail): Option[String] = { Option(mail.address) } def deleteById(mail: String, owner: String): Int = { AppDB.mailTable.deleteWhere(m => (m.address === mail) and (m.owner === owner)) } } @JsonIgnoreProperties(Array("owner")) case class Mail( address: String, owner: String = "") extends KeyedEntity[(String, String)] { override def id: (String, String) = (address, owner) def insert: Mail = AppDB.mailTable.insert(this) }
Example 7
Source File: MetricParameter.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.metrics import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import scala.util.Try object MetricParameter { def applyWithoutOwner(name: String, value: String): MetricParameter = { new MetricParameter("", name, value) } def unapplyWithoutOwner(arg: MetricParameter): Option[(String, String)] = { Try((arg.name, arg.value)).toOption } def deleteByName(name: String, owner: String): Int = { AppDB.metricParametersTable.deleteWhere(m => (m.name === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.metricParametersTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class MetricParameter( owner: String, name: String, value: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, name) def insert(): MetricParameter = AppDB.metricParametersTable.insert(this) def insertWithOwner(owner: String): MetricParameter = AppDB.metricParametersTable .insert(MetricParameter(owner,this.name,this.value)) }
Example 8
Source File: MetricMeta.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.meta import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import dbmodel.metrics.Metric.MetricType.MetricType import org.squeryl.PrimitiveTypeMode.{from, select, _} import org.squeryl.annotations.Column import org.squeryl.{KeyedEntity, Query} object MetricMeta { def all(filter: Option[MetricType]): Query[MetricMeta] = { filter match { case Some(x:MetricType) => from(AppDB.metricMetaTable)(tbl => where(tbl.metricType === x.toString) select tbl) case _ => from(AppDB.metricMetaTable)(tbl => select(tbl)) } } def getShortList(filter: Option[MetricType]): Query[String] = { filter match { case Some(x:MetricType) => from(AppDB.metricMetaTable)(tbl => where(tbl.metricType === x.toString) select tbl.id).distinct case _ => from(AppDB.metricMetaTable)(tbl => select(tbl.id)).distinct } } def getById(id: String): Query[MetricMeta] = { from(AppDB.metricMetaTable)(tbl => where(tbl.id === id) select tbl) } def getParamsById(id: String): Query[MetricParamMeta] = { from(AppDB.metricParamMetaTable)(tbl => where(tbl.metric === id) select tbl) } } @JsonIgnoreProperties(Array("metric")) case class MetricParamMeta( metric: String, name: String, @Column("type") paramType: String, description: Option[String], @Column("is_optional") isOptional: Boolean ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (metric, name) } case class MetricMeta( @Column("name") id: String, @Column("type") metricType: String, description: Option[String], @Column("is_statusable") isStatusable: Boolean, @Column("is_multicolumn") isMulticolumn: Boolean ) extends KeyedEntity[String] { lazy val parameters: Iterator[MetricParamMeta] = AppDB.metaMetricToParameters.left(this).iterator }
Example 9
Source File: CheckMeta.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.meta import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import dbmodel.checks.Check.CheckType.CheckType import org.squeryl.PrimitiveTypeMode.{from, select, _} import org.squeryl.Query import org.squeryl.annotations.Column object CheckMeta { def all(filter: Option[CheckType]): Query[CheckMeta] = { filter match { case Some(x:CheckType) => from(AppDB.checkMetaTable)(tbl => where(tbl.checkType === x.toString.toLowerCase) select tbl ) case _ => from(AppDB.checkMetaTable)(tbl => select(tbl)) } } def getShortList(filter: Option[CheckType]): Query[String] = { filter match { case Some(x:CheckType) => from(AppDB.checkMetaTable)(tbl => where(tbl.checkType === x.toString.toLowerCase()) select tbl.id).distinct case _ => from(AppDB.checkMetaTable)(tbl => select(tbl.id)).distinct } } def getById(id: String): Query[CheckMeta] = { from(AppDB.checkMetaTable)(tbl => where(tbl.id === id) select tbl) } def getTrendCheckRuleIds(): Query[String] = { from(AppDB.checkRuleTable)(r => select(r.name)) } def getTrendCheckRules: Query[CheckRule] = { from(AppDB.checkRuleTable)(r => select(r)) } def modeToString(withMetric: Boolean): String = if (withMetric) "with Metric" else "with Threshold" } @JsonIgnoreProperties(Array("check","withMetric")) case class CheckParamMeta( @Column("check_name") check: String, @Column("with_metric") withMetric: Boolean, name: String, @Column("type") paramType: String, description: Option[String] ) case class CheckRule( name: String, description: Option[String] ) case class CheckMeta( @Column("name") id: String, @Column("type") checkType: String, description: Option[String], @Column("with_metric") withMetric: Boolean ) { lazy val parameters: Query[CheckParamMeta] = from(AppDB.checkParamMetaTable)(p => where(p.check === this.id and p.withMetric === this.withMetric) select p) }
Example 10
Source File: CheckParameter.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package dbmodel.checks import com.fasterxml.jackson.annotation.JsonIgnoreProperties import dbmodel.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import scala.util.Try object CheckParameter { def applyWithoutOwner(name: String, value: String): CheckParameter = { new CheckParameter("", name, value) } def unapplyWithoutOwner(arg: CheckParameter): Option[(String, String)] = { Try((arg.name, arg.value)).toOption } def deleteByName(name: String, owner: String): Int = { AppDB.checkParametersTable.deleteWhere(m => (m.name === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.checkParametersTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class CheckParameter( owner: String, name: String, value: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, name) def insert(): CheckParameter = AppDB.checkParametersTable.insert(this) def insertWithOwner(owner: String): CheckParameter = AppDB.checkParametersTable .insert(CheckParameter(owner,this.name,this.value)) }
Example 11
Source File: ProjectJsonResponse.scala From versioneye_sbt_plugin with MIT License | 5 votes |
package com.versioneye import com.fasterxml.jackson.annotation.JsonIgnoreProperties @JsonIgnoreProperties(ignoreUnknown = true) class ProjectJsonResponse { private var name: String = null private var id: String = null private var dep_number: Integer = null private var out_number: Integer = null private var licenses_red: Integer = 0 private var licenses_unknown: Integer = 0 def getLicenses_red: Integer = { return licenses_red } def setLicenses_red(licenses_red: Integer) { this.licenses_red = licenses_red } def getLicenses_unknown: Integer = { return licenses_unknown } def setLicenses_unknown(licenses_unknown: Integer) { this.licenses_unknown = licenses_unknown } def getName: String = { return name } def setName(name: String) { this.name = name } def getId: String = { return id } def setId(id: String) { this.id = id } def getDep_number: Integer = { return dep_number } def setDep_number(dep_number: Integer) { this.dep_number = dep_number } def getOut_number: Integer = { return out_number } def setOut_number(out_number: Integer) { this.out_number = out_number } }
Example 12
Source File: TargetToChecks.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.targets import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import org.squeryl.annotations.Column object TargetToChecks { def applyWithoutOwner(check: String): TargetToChecks = { TargetToChecks(check) } def unapplyWithoutOwner(ttc: TargetToChecks): Option[String] = { Option(ttc.checkId) } def deleteByCheck(check: String): Int = { AppDB.targetToChecksTable.deleteWhere(m => m.checkId === check) } def deleteById(check: String, owner: String): Int = { AppDB.targetToChecksTable.deleteWhere(m => (m.checkId === check) and (m.targetId === owner)) } def updateChecks(prev: String, curr: String): Int = { update(AppDB.targetToChecksTable)(ttc => where(ttc.checkId === prev) set(ttc.checkId := curr) ) } def getAvailableTargetsForCheck(check: String): Set[String] = { from(AppDB.targetTable)(tar => where(tar.targetType === "SYSTEM" and (tar.id notIn from(AppDB.targetToChecksTable)(ttc => where(ttc.checkId === check) select ttc.targetId))) select tar.id).toSet } def addTargetForCheck(check: String, list: Set[String]): Unit = { val ttcList: Set[TargetToChecks] = list map (x => TargetToChecks(check, x)) AppDB.targetToChecksTable.insert(ttcList) } } @JsonIgnoreProperties(Array("targetId")) case class TargetToChecks( @Column("check_id") checkId: String, @Column("target_id") targetId: String = "" ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (checkId, targetId) def insert: TargetToChecks = AppDB.targetToChecksTable.insert(this) }
Example 13
Source File: Mail.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.targets import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ object Mail { def applyWithoutOwner(mail: String): Mail = { Mail(mail) } def unapplyWithoutOwner(mail: Mail): Option[String] = { Option(mail.address) } def deleteById(mail: String, owner: String): Int = { AppDB.mailTable.deleteWhere(m => (m.address === mail) and (m.owner === owner)) } } @JsonIgnoreProperties(Array("owner")) case class Mail( address: String, owner: String = "") extends KeyedEntity[(String, String)] { override def id: (String, String) = (address, owner) def insert: Mail = AppDB.mailTable.insert(this) }
Example 14
Source File: MetricParameter.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.metrics import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import scala.util.Try object MetricParameter { def applyWithoutOwner(name: String, value: String): MetricParameter = { new MetricParameter("", name, value) } def unapplyWithoutOwner(arg: MetricParameter): Option[(String, String)] = { Try((arg.name, arg.value)).toOption } def deleteByName(name: String, owner: String): Int = { AppDB.metricParametersTable.deleteWhere(m => (m.name === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.metricParametersTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class MetricParameter( owner: String, name: String, value: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, name) def insert(): MetricParameter = AppDB.metricParametersTable.insert(this) def insertWithOwner(owner: String): MetricParameter = AppDB.metricParametersTable .insert(MetricParameter(owner,this.name,this.value)) }
Example 15
Source File: MetricMeta.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.meta import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import models.metrics.Metric.MetricType.MetricType import org.squeryl.PrimitiveTypeMode.{from, select, _} import org.squeryl.annotations.Column import org.squeryl.{KeyedEntity, Query} object MetricMeta { def all(filter: Option[MetricType]): Query[MetricMeta] = { filter match { case Some(x:MetricType) => from(AppDB.metricMetaTable)(tbl => where(tbl.metricType === x.toString) select tbl) case _ => from(AppDB.metricMetaTable)(tbl => select(tbl)) } } def getShortList(filter: Option[MetricType]): Query[String] = { filter match { case Some(x:MetricType) => from(AppDB.metricMetaTable)(tbl => where(tbl.metricType === x.toString) select tbl.id).distinct case _ => from(AppDB.metricMetaTable)(tbl => select(tbl.id)).distinct } } def getById(id: String): Query[MetricMeta] = { from(AppDB.metricMetaTable)(tbl => where(tbl.id === id) select tbl) } def getParamsById(id: String): Query[MetricParamMeta] = { from(AppDB.metricParamMetaTable)(tbl => where(tbl.metric === id) select tbl) } } @JsonIgnoreProperties(Array("metric")) case class MetricParamMeta( metric: String, name: String, @Column("type") paramType: String, description: Option[String], @Column("is_optional") isOptional: Boolean ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (metric, name) } case class MetricMeta( @Column("name") id: String, @Column("type") metricType: String, description: Option[String], @Column("is_statusable") isStatusable: Boolean, @Column("is_multicolumn") isMulticolumn: Boolean ) extends KeyedEntity[String] { lazy val parameters: Iterator[MetricParamMeta] = AppDB.metaMetricToParameters.left(this).iterator }
Example 16
Source File: CheckMeta.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.meta import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import models.checks.Check.CheckType.CheckType import org.squeryl.PrimitiveTypeMode.{from, select, _} import org.squeryl.Query import org.squeryl.annotations.Column object CheckMeta { def all(filter: Option[CheckType]): Query[CheckMeta] = { filter match { case Some(x:CheckType) => from(AppDB.checkMetaTable)(tbl => where(tbl.checkType === x.toString.toLowerCase) select tbl ) case _ => from(AppDB.checkMetaTable)(tbl => select(tbl)) } } def getShortList(filter: Option[CheckType]): Query[String] = { filter match { case Some(x:CheckType) => from(AppDB.checkMetaTable)(tbl => where(tbl.checkType === x.toString.toLowerCase()) select tbl.id).distinct case _ => from(AppDB.checkMetaTable)(tbl => select(tbl.id)).distinct } } def getById(id: String): Query[CheckMeta] = { from(AppDB.checkMetaTable)(tbl => where(tbl.id === id) select tbl) } def getTrendCheckRuleIds(): Query[String] = { from(AppDB.checkRuleTable)(r => select(r.name)) } def getTrendCheckRules: Query[CheckRule] = { from(AppDB.checkRuleTable)(r => select(r)) } def modeToString(withMetric: Boolean): String = if (withMetric) "with Metric" else "with Threshold" } @JsonIgnoreProperties(Array("check","withMetric")) case class CheckParamMeta( @Column("check_name") check: String, @Column("with_metric") withMetric: Boolean, name: String, @Column("type") paramType: String, description: Option[String] ) case class CheckRule( name: String, description: Option[String] ) case class CheckMeta( @Column("name") id: String, @Column("type") checkType: String, description: Option[String], @Column("with_metric") withMetric: Boolean ) { lazy val parameters: Query[CheckParamMeta] = from(AppDB.checkParamMetaTable)(p => where(p.check === this.id and p.withMetric === this.withMetric) select p) }
Example 17
Source File: CheckParameter.scala From DataQuality with GNU Lesser General Public License v3.0 | 5 votes |
package models.checks import com.fasterxml.jackson.annotation.JsonIgnoreProperties import models.AppDB import org.squeryl.KeyedEntity import org.squeryl.PrimitiveTypeMode._ import scala.util.Try object CheckParameter { def applyWithoutOwner(name: String, value: String): CheckParameter = { new CheckParameter("", name, value) } def unapplyWithoutOwner(arg: CheckParameter): Option[(String, String)] = { Try((arg.name, arg.value)).toOption } def deleteByName(name: String, owner: String): Int = { AppDB.checkParametersTable.deleteWhere(m => (m.name === name) and (m.owner === owner)) } def deleteByOwner(owner: String): Int = { AppDB.checkParametersTable.deleteWhere(m => m.owner === owner) } } @JsonIgnoreProperties(Array("owner")) case class CheckParameter( owner: String, name: String, value: String ) extends KeyedEntity[(String, String)] { override def id: (String, String) = (owner, name) def insert(): CheckParameter = AppDB.checkParametersTable.insert(this) def insertWithOwner(owner: String): CheckParameter = AppDB.checkParametersTable .insert(CheckParameter(owner,this.name,this.value)) }
Example 18
Source File: StrimziClient.scala From kafka-lag-exporter with Apache License 2.0 | 5 votes |
package com.lightbend.kafkalagexporter.watchers import java.lang import com.fasterxml.jackson.annotation.JsonIgnoreProperties import com.lightbend.kafkalagexporter.KafkaCluster import io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinitionBuilder import io.fabric8.kubernetes.client.{Watcher => FWatcher, _} import io.fabric8.kubernetes.client.dsl.FilterWatchListMultiDeletable import io.fabric8.kubernetes.internal.KubernetesDeserializer import io.fabric8.kubernetes.api.builder.{Function => Fabric8Function} import scala.util.control.NonFatal object StrimziClient { def apply(clusterWatcher: Watcher.Events): Watcher.Client = new StrimziClient(clusterWatcher) // Ignore all custom fields (i.e. the spec) of the Kafka resource. We only care about its metadata. @JsonIgnoreProperties(ignoreUnknown = true) class KafkaResource extends CustomResource object KafkaResource { val name = "kafkas.kafka.strimzi.io" val kind = "Kafka" val shortNames = "k" val plural = "kafkas" val group = "kafka.strimzi.io" val groupVersion = s"$group/v1alpha1" } class KafkaResourceList extends CustomResourceList[KafkaResource] class KafkaResourceDoneable(val resource: KafkaResource, val function: Fabric8Function[KafkaResource, KafkaResource]) extends CustomResourceDoneable[KafkaResource](resource, function) KubernetesDeserializer.registerCustomKind(KafkaResource.groupVersion, KafkaResource.kind, classOf[KafkaResource]) private val kafkaDefinition = new CustomResourceDefinitionBuilder() .withApiVersion(KafkaResource.groupVersion) .withNewMetadata().withName(KafkaResource.name).endMetadata() .withNewSpec().withGroup(KafkaResource.group).withVersion(KafkaResource.groupVersion).withScope("Cluster")//.withScope("Namespaced") .withNewNames().withKind(KafkaResource.kind).withShortNames(KafkaResource.shortNames).withPlural(KafkaResource.plural).endNames().endSpec() .build() def createClient(client: DefaultKubernetesClient): FilterWatchListMultiDeletable[KafkaResource, KafkaResourceList, lang.Boolean, Watch, FWatcher[KafkaResource]] = { client.customResources(kafkaDefinition, classOf[KafkaResource], classOf[KafkaResourceList], classOf[KafkaResourceDoneable]).inAnyNamespace() } } class StrimziClient(clusterWatcher: Watcher.Events) extends Watcher.Client { import StrimziClient._ private val k8sClient: DefaultKubernetesClient = new DefaultKubernetesClient() private val client: FilterWatchListMultiDeletable[KafkaResource, KafkaResourceList, lang.Boolean, Watch, FWatcher[KafkaResource]] = createClient(k8sClient) private def resourceToCluster(resource: KafkaResource): KafkaCluster = { val name = resource.getMetadata.getName val namespace = resource.getMetadata.getNamespace val bootstrapBrokerHost: String = s"$name-kafka-bootstrap.$namespace:9092" KafkaCluster(resource.getMetadata.getName, bootstrapBrokerHost) } def close(): Unit = k8sClient.close() try { client.watch(new FWatcher[KafkaResource]() { override def eventReceived(action: FWatcher.Action, resource: KafkaResource): Unit = action match { case FWatcher.Action.ADDED => clusterWatcher.added(resourceToCluster(resource)) case FWatcher.Action.DELETED => clusterWatcher.removed(resourceToCluster(resource)) case _ => throw new Exception(s"Unhandled Watcher.Action: $action: ${resource.getMetadata}") } override def onClose(e: KubernetesClientException): Unit = { if (e != null) { clusterWatcher.error(e) } } }) } catch { case NonFatal(e) => clusterWatcher.error(e) } }
Example 19
Source File: ExceptionFormattingDependencyAnalyzer.scala From exodus with MIT License | 5 votes |
package com.wix.bazel.migrator.analyze import com.fasterxml.jackson.annotation.{JsonIgnoreProperties, JsonTypeInfo} import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.scala.DefaultScalaModule import com.wix.bazel.migrator.model.SourceModule import com.wix.bazel.migrator.transform.failures.{AnalyzeException, AnalyzeFailure} class ExceptionFormattingDependencyAnalyzer(dependencyAnalyzer: DependencyAnalyzer) extends DependencyAnalyzer { private val om = new ObjectMapper().registerModule(DefaultScalaModule) .addMixIn(classOf[AnalyzeFailure], classOf[AnalyzeFailureMixin]) .addMixIn(classOf[Throwable], classOf[ThrowableMixin]) .addMixIn(classOf[SourceModule], classOf[IgnoringMavenDependenciesMixin]) override def allCodeForModule(module: SourceModule): List[Code] = try { dependencyAnalyzer.allCodeForModule(module) } catch { case e: AnalyzeException => val message = om.writerWithDefaultPrettyPrinter().writeValueAsString(e.failure) throw new RuntimeException(message + """|***Detailed error is in a prettified json which starts above*** |***Inner most AnalyzeFailure has root cause, look for it*** |More info at https://github.com/wix-private/bazel-tooling/blob/master/migrator/docs |""".stripMargin) } } @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "__class") trait AnalyzeFailureMixin @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "__class") abstract class ThrowableMixin @JsonIgnoreProperties(Array("dependencies")) trait IgnoringMavenDependenciesMixin