Migrate taxonomy reference field into entity reference - drupal-8

Am trying to migrate a taxonomy-reference field attached to a field_collection entity-type (Drupal 7) into an entity-reference field attached to a paragraphs entity-type (Drupal 8.6).
Although it seems one of the basic tasks to do while migration but I couldn't find a clear reference of how to do it.
id: d7_field_collection_field_name
label: My Field name
migration_tags:
- Drupal 7
migration_group: migrate_drupal_7
source:
plugin: d7_custom_source_plugin
process:
field_title:
plugin: get
source: field_title
field_job_category:
plugin: get
source: field_job_category
destination:
plugin: 'entity_reference_revisions:paragraph'
default_bundle: my_paragraphs_bundle
migration_dependencies:
required:
- upgrade_d7_field
- upgrade_d7_node_type
- upgrade_d7_field_collection_type
- upgrade_d7_field_instance
The migration process is explained here: https://www.mtech-llc.com/blog/ada-hernandez/migration-field-collection-d7-paragraphs-node-d8
So, field_job_category is not working. I tried so many ways in process plugins without luck. For example I used:
field_job_category:
plugin: migration_lookup
migration: upgrade_d7_taxonomy_term_job_categories
source: term_id
Then tried to use sources since am using Drupal 8.6
field_job_category:
plugin: migration_lookup
migration: upgrade_d7_taxonomy_term_job_categories
sources:
upgrade_d7_taxonomy_term_job_categories:
- term_id
I believe its a configuration mistake under field_job_category, but i couldn't figure it out yet.
Your help is much appreciated!

This has been resolved by doing two things.
First, use sub_process process plugin for my field.
field_job_category:
-
plugin: sub_process
source: field_job_category
process:
target_id: tid
Finally, implement hook_migrate_prepare_row() to provide data with right structure to be consumed by the above sub_process
$row->setSourceProperty($field_name, $new_value);
And $new_value should be
Array
(
[0] => Array
(
[tid] => Term ID
)
)
Hope this helps! Cheers.

Related

Drupal 8 Rest API

My Custom API's are working fine, I've deployed code on staging Server but I'am getting below error.
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\rest\Plugin\Type\ResourcePluginManager are: dblog, file:upload, entity:block, entity:block_content_type, entity:block_content, entity:comment, entity:comment_type, entity:config_pages_type, entity:config_pages, entity:contact_form, entity:contact_message, entity:editor, entity:field_config, entity:field_storage_config, entity:file, entity:filter_format, entity:flagging, entity:flag, entity:google_api_service_client, entity:google_api_client, entity:image_style, entity:menu_link_content, entity:node, entity:node_type, entity:page_variant, entity:page, entity:path_alias, entity:rdf_mapping, entity:rest_resource_config, entity:search_api_task, entity:search_api_server, entity:search_api_index, entity:search_api_autocomplete_search, entity:shortcut_set, entity:shortcut, entity:social_auth, entity:menu, entity:action, entity:taxonomy_term, entity:taxonomy_vocabulary, entity:tour, entity:ultimate_cron_job, entity:user, entity:user_role, entity:webform_options, entity:webform, entity:webform_submission, entity:webform_access_group, entity:webform_access_type, entity:webform_image_select_images, entity:webform_options_custom, entity:view, entity:paragraph, entity:paragraphs_type, entity:base_field_override, entity:entity_view_display, entity:entity_view_mode, entity:entity_form_mode, entity:entity_form_display, entity:date_format, user_registration in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /home1/tourcode/public_html/''/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)
Thanks in Advance.
Drupal is looking for a plugin with empty string as a name.
I also noticed have some kind of an empty string in your path. (between public_html and web)
/home1/tourcode/public_html/''/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php
It looks like the configuration of your server has a problem.

How can set dynamic attribute value in .kitchen.yml

I am using kitchen with ec2 driver. I would like to add Name tag to ec2 instances based on the instance name kitchen creates. If I had a 'default' suite and was using centos7.2, kitchen list would name the instance 'default-centos-72'.
I could hard code something like this:
suites:
- name: default
driver_config:
tags: { "Name": "kitchen-default-centos-72" }
But what I'd really like is something like this:
suites:
- name: default
driver_config:
tags: { "Name": <%= figure out instance name and prepend kitchen- %> }
My example suggests using ERB which seems like the way to go to me. But I can't seem to figure out what code to use to get the name of the instance. I tried using a bit of Kitchen::Config.new... but couldn't figure out something that worked. Any suggestions would be much appreciated.
Took me a while but I finally ran across an example that may have showed me the light. While looking through the InSpec options for kitchen I found you can have it output a results file with the platform and suite name that was used during the test run. The below syntax in your platforms: block nested under the driver: option should work. I haven't tested this by examining the instance during a run but hopefully I can find some time to do that soon. If it doesn't work let me know and we can tweak it until it does.
platforms:
- name: ubuntu
driver:
tags:
Name: test-kitchen-%{platform}-%{suite}
How this should work is that the .kitchen.yml file gets run through an ERB pre-processor so the %{platform} resolves to an instance variable during the loop across the platforms and suites arrays.
As far as I can tell there seems to be no straightforward way to include instance properties in the kitchen YAML. I added the following snippet to my kitchen.yml to check what is available in the kitchen YAML's ERB namespace:
<%
puts "Instance vars: #{instance_variables}"
puts "Local vars: #{local_variables}"
puts "Global vars: #{global_variables}"
puts "Methods: #{methods}"
%>
The results when running kitchen create for a specific instance were disappointing, containing nothing that looks like instance specification data:
Instance vars: []
Local vars: [:_erbout, :spec, :bin_file]
Global vars: [:$-0, :$\, :$DEBUG, :$-W, :$0, :$-d, :$-p, :$PROGRAM_NAME, :$:, :$-I, :$LOAD_PATH, :$", :$LOADED_FEATURES, :$,, :$/, :$INPUT_LINE_NUMBER, :$-l, :$-a, :$INPUT_RECORD_SEPARATOR, :$ORS, :$OUTPUT_RECORD_SEPARATOR, :$PROCESS_ID, :$NR, :$#, :$!, :$DEFAULT_INPUT, :$PID, :$PREMATCH, :$CHILD_STATUS, :$LAST_MATCH_INFO, :$LAST_READ_LINE, :$DEFAULT_OUTPUT, :$MATCH, :$fileutils_rb_have_lchown, :$POSTMATCH, :$LAST_PAREN_MATCH, :$IGNORECASE, :$ARGV, :$fileutils_rb_have_lchmod, :$stdin, :$stdout, :$stderr, :$>, :$<, :$., :$FILENAME, :$-i, :$*, :$SAFE, :$thor_runner, :$_, :$~, :$;, :$-F, :$?, :$$, :$ERROR_INFO, :$&, :$`, :$', :$+, :$=, :$KCODE, :$-K, :$ERROR_POSITION, :$FS, :$FIELD_SEPARATOR, :$OFS, :$OUTPUT_FIELD_SEPARATOR, :$RS, :$VERBOSE, :$-v, :$-w]
Methods: [:inspect, :to_s, :to_yaml, :to_json, :instance_variable_defined?, :remove_instance_variable, :instance_of?, :kind_of?, :is_a?, :tap, :methods, :instance_variable_set, :protected_methods, :instance_variables, :instance_variable_get, :private_methods, :public_methods, :method, :define_singleton_method, :public_send, :singleton_method, :public_method, :extend, :to_enum, :enum_for, :<=>, :===, :=~, :!~, :eql?, :respond_to?, :freeze, :object_id, :send, :display, :class, :nil?, :hash, :dup, :singleton_class, :clone, :then, :itself, :yield_self, :untaint, :taint, :tainted?, :untrusted?, :trust, :frozen?, :untrust, :singleton_methods, :equal?, :!, :__id__, :==, :instance_exec, :!=, :instance_eval, :__send__]
The local variable spec looked hopeful at first, but turned out to be a GemSpec object.
All things considered, you will probably have to create a convention to always specify the instance in some external way. You could use for example an environment variable of your choice, which you could then access in the template as <%= ENV['<VARNAME>'] %> (where you replace <VARNAME> with the name of your environment variable). There are probably other ways of getting the information in there, but you will still have to specify it in more places than just the Test Kitchen command.

uncomment it to see your plugin in "powerbivisualsplayground" plugins

How Can i see my plugin in "PowerBIVisualsPlayground" plugins list !
So when i create a iVisual it created some default code where on the plugin list it says uncomment it to see your plugin in "powerbivisualsplayground" plugins
So i followed it and uncomment the code ---
i have created a IVisual i the PowerBI visual ---
/* creating ivisualplugin that is used to represent ivisual. */
//uncomment it to see your plugin in "powerbivisualsplayground" plugins list
//remember to finally move it to plugins.ts
module powerbi.visuals.plugins {
export var newvisual: ivisualplugin = {
name: 'newvisual',
capabilities: newvisual.capabilities,
create: () => new newvisual()
};
}
i have uncommented the default code to see my Visual name list o the PowerBI Plugin list but still i can not see my plugin name in the PowerBIVisualsPlayground" plugins list.
I have also tried to move my code to plugins.ts but still no result !!
export var newvisual: ivisualplugin = {
name: 'newvisual',
watermarkKey: 'newvisual',
capabilities: newvisual.capabilities,
create: () => new newvisual()
};
Do anyone knows what i am doing wrong !
So my question is again
**How can i see my plugin name in the PowerBI Visual plugin List !**
Any kind of advice or help will be really appreciable ! Thanks
there are couple of error in your code.
in the first line ivisualplugin it Should be IVisualPlugin
Change your class and capabilities name from newvisual to Newvisual
So the answer is :
export var newvisual: IVisualPlugin = {
name: 'newvisual',
capabilities: Newvisual.capabilities,
create: () => new Newvisual()
};
Hope it will help you.

emberjs getEach method does not work as expected

I have the following code which I expect to return [1000] but returns [undefined]:
this.get('details').getEach('gross_total')
But
this.get('details')[0].get('gross_total')
does work and returns 1000.
I am using rc3 right now. The same code in rc1 worked fine.
My persistence layer is taken from discourse. The relevant models are below. Invoice has_many details
App.Invoice = App.Model.extend App.Commentable,
invoice_number: App.Attr('string')
description: App.Attr('string')
issue_date: App.Attr('date')
due_date: App.Attr('date')
contact: App.BelongsTo('App.Contact', "contacts")
details: App.HasMany('App.InvoiceDetail', "detail_ids")
payments: App.HasMany('App.Payment', "payment_ids")
invoice_status: App.Attr('string')
comments: App.HasMany('App.Comment', "comment_ids")
App.InvoiceDetail = App.Model.extend App.DestroyableChild,
detail_no: App.Attr('int')
description: App.Attr('string')
quantity: App.Attr('float')
unit_price: App.Attr('currency')
consumption_tax_rate: App.Attr('float')
vat_rate: App.Attr('float')
discount_type: App.Attr('string')
discount_value: App.Attr('currency')
product: App.BelongsTo('App.Product', 'products')
I have seen this issue when prototyping require.js use for loading my app. Using ember.js 1.0.0-rc.1.
I traced it down to having two ember.js script instances (each of which contains its own different Ember.META_KEY) which implied the illogical behavior.
So the answer seems to be to make sure only a single ember.js copy is loaded within the browser window context.

Single Table Inheritance and Yaml configuration

I want to use in my project Single Table Inheritance for symfony2/doctrine, but I can't find any working examples with yaml configuration for it. In official documentation there is only annotation configuration presented. I found xml examples, but I want to use yaml configuration. Can somebody help and share with some working code?
Okay built-in converter saves life.
In order to save time this an example of inheritance converted into yaml :
#file: Resources/config/doctrine/Person.orm.yml
Person:
type: entity
table: null
fields:
id:
type: integer
id: true
generator:
strategy: AUTO
inheritanceType: SINGLE_TABLE
discriminatorColumn:
name: discr
type: string
length: 255
discriminatorMap:
person: Person
employee: Employee
lifecycleCallbacks: { }
#file: Resources/config/doctrine/Employee.orm.yml
Employee:
type: entity
table: null
lifecycleCallbacks: { }
Here is an example of YAML markup:
Entities config files should be put into src/Acme/StoreBundle/Resources/config/doctrine/<EntityName>.orm.yml according to reference.
Also built-in converter can be used: how to model inheritance in doctrine2 with yaml?