Skip to content
This repository has been archived by the owner on Mar 11, 2021. It is now read-only.

Fieldtype.ConvertToModelWithType #2274

Merged
merged 3 commits into from
Sep 5, 2018
Merged

Conversation

kwk
Copy link
Collaborator

@kwk kwk commented Sep 5, 2018

TL;DR

When changing the type of a work item we have to check if fields are compatible. This logic was deeply embedded in the work item repository but it can be outsourced and made available to other pieces of the code as well.

About

ConvertToModelWithType tries to find way to convert the value v from the current FieldType to the other FieldType in model representation; returns error otherwise.

Examples

  • For example if the given value v is a string and the other FieldType is a string list, we will return the value v as an array of interface{} objects.
  • Let's say the current FieldType is a string list and the other FieldType is a single string field, then we check if the value v has only one element and return that instead of the whole list.

@alien-ike
Copy link

alien-ike commented Sep 5, 2018

Ike Plugins (test-keeper)

Thank you @kwk for this contribution!

It seems that this PR already contains some added or changed tests. Good job!

For more information please head over to official documentation. You can find there how to configure the plugin.

@kwk kwk requested a review from jarifibrahim September 5, 2018 10:00
@alien-ike alien-ike changed the title WIP: Fieldtype.ConvertToModelWithType Fieldtype.ConvertToModelWithType Sep 5, 2018
@kwk kwk added the 🚫 hold label Sep 5, 2018
@kwk kwk changed the title Fieldtype.ConvertToModelWithType WIP: Fieldtype.ConvertToModelWithType Sep 5, 2018
@codecov-io
Copy link

codecov-io commented Sep 5, 2018

Codecov Report

Merging #2274 into master will increase coverage by 0.09%.
The diff coverage is 90.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2274      +/-   ##
==========================================
+ Coverage   69.39%   69.49%   +0.09%     
==========================================
  Files         175      175              
  Lines       16392    16444      +52     
==========================================
+ Hits        11376    11428      +52     
- Misses       3923     3924       +1     
+ Partials     1093     1092       -1
Impacted Files Coverage Δ
workitem/field_definition.go 86.95% <ø> (+4.65%) ⬆️
workitem/workitem_repository.go 67.84% <100%> (-0.47%) ⬇️
workitem/simple_type.go 82.66% <88.23%> (+0.71%) ⬆️
controller/workitem.go 78.83% <0%> (+0.56%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6774109...041dacb. Read the comment docs.

@kwk kwk changed the title WIP: Fieldtype.ConvertToModelWithType Fieldtype.ConvertToModelWithType Sep 5, 2018
@kwk kwk merged commit c0eaf33 into fabric8-services:master Sep 5, 2018
@kwk kwk deleted the is-compatible branch September 5, 2018 10:47
kwk added a commit to openshiftio/saas-openshiftio that referenced this pull request Sep 6, 2018
# About
This description was generated using this script:
```sh
#!/bin/bash
set -e
GHORG=${GHORG:-fabric8-services}
GHREPO=${GHREPO:-fabric8-wit}
cat <<EOF
# About
This description was generated using this script:
\`\`\`sh
`cat $0`
\`\`\`
Invoked as:

    `echo GHORG=${GHORG} GHREPO=${GHREPO} $(basename $0) ${@:1}`

# Changes
EOF
git log \
  --pretty="%n**Commit:** https://github.com/${GHORG}/${GHREPO}/commit/%H%n**Author:** %an (%ae)%n**Date:** %aI%n%n%s%n%n%b%n%n----%n" \
  --reverse ${@:1} \
  | sed -E "s/([\s|\(| ])#([0-9]+)/\1${GHORG}\/${GHREPO}#\2/g"
```
Invoked as:

    GHORG=fabric8-services GHREPO=fabric8-wit git-log-pr.sh 677410943faa4c4d403f15f9639a8a15b4c19be9..upstream/master

# Changes

**Commit:** fabric8-services/fabric8-wit@c0eaf33
**Author:** Konrad Kleine (193408+kwk@users.noreply.github.com)
**Date:** 2018-09-05T12:47:43+02:00

Fieldtype.ConvertToModelWithType (fabric8-services/fabric8-wit#2274)

# TL;DR

When changing the type of a work item we have to check if fields are compatible. This logic was deeply embedded in the work item repository but it can be outsourced and made available to other pieces of the code as well.

# About

`ConvertToModelWithType` tries to find way to convert the value `v` from the current `FieldType` to the other `FieldType` in model representation; returns `error` otherwise.

# Examples

* For example if the given value `v` is a `string` and the other `FieldType` is a string list, we will return the value `v` as an array of `interface{}` objects. 
* Let's say the current `FieldType` is a string list and the other `FieldType` is a single `string` field, then we check if the value `v` has only one element and return that instead of the whole list.

----


**Commit:** fabric8-services/fabric8-wit@4909a90
**Author:** Konrad Kleine (193408+kwk@users.noreply.github.com)
**Date:** 2018-09-06T13:17:10+02:00

Search by parent (fabric8-services/fabric8-wit#2275)

Allow to search for work items by `parent.id` and `parent.number`.

See https://openshift.io/openshiftio/Openshift_io/plan/detail/450.
See fabric8-services/fabric8-wit#2244.


----
kwk added a commit to openshiftio/saas-openshiftio that referenced this pull request Sep 6, 2018
**Commit:** fabric8-services/fabric8-wit@c0eaf33
**Author:** Konrad Kleine (193408+kwk@users.noreply.github.com)
**Date:** 2018-09-05T12:47:43+02:00

Fieldtype.ConvertToModelWithType (fabric8-services/fabric8-wit#2274)

# TL;DR

When changing the type of a work item we have to check if fields are compatible. This logic was deeply embedded in the work item repository but it can be outsourced and made available to other pieces of the code as well.

# About

`ConvertToModelWithType` tries to find way to convert the value `v` from the current `FieldType` to the other `FieldType` in model representation; returns `error` otherwise.

# Examples

* For example if the given value `v` is a `string` and the other `FieldType` is a string list, we will return the value `v` as an array of `interface{}` objects. 
* Let's say the current `FieldType` is a string list and the other `FieldType` is a single `string` field, then we check if the value `v` has only one element and return that instead of the whole list.

----

**Commit:** fabric8-services/fabric8-wit@4909a90
**Author:** Konrad Kleine (193408+kwk@users.noreply.github.com)
**Date:** 2018-09-06T13:17:10+02:00

Search by parent (fabric8-services/fabric8-wit#2275)

Allow to search for work items by `parent.id` and `parent.number`.

See https://openshift.io/openshiftio/Openshift_io/plan/detail/450.
See fabric8-services/fabric8-wit#2244.

----
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants