class Cacofonix::APAProduct

Public Instance Methods

add_bic_subject(code) click to toggle source

add a BIC subject code to the product

# File lib/cacofonix/wrappers/apa_product.rb, line 167
def add_bic_subject(code)
  add_subject code, "12"
end
add_bisac_subject(code) click to toggle source

add a BISAC subject code to the product

# File lib/cacofonix/wrappers/apa_product.rb, line 178
def add_bisac_subject(code)
  add_subject code, "10"
end
add_contributor(str, role = "A01") click to toggle source

set a new contributor to this product str should be the contributors name inverted (Healy, James)

# File lib/cacofonix/wrappers/apa_product.rb, line 150
def add_contributor(str, role = "A01")
  contrib = ::Cacofonix::Contributor.new
  contrib.sequence_number = product.contributors.size + 1
  contrib.contributor_role = role
  contrib.person_name_inverted = str
  product.contributors << contrib
end
agent_name() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 536
def agent_name
  reps = product.market_representations.first
  return nil if reps.nil?
  reps.agent_name
end
agent_name=(value) click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 542
def agent_name=(value)
  reps = product.market_representations.first
  if reps.nil?
    reps = Cacofonix::MarketRepresentation.new
    product.market_representations << reps
  end
  reps.agent_name = value.to_s
end
bic_subjects() click to toggle source

return an array of BIC subjects for this title could be version 1 or version 2, most ONIX files don't specifiy

# File lib/cacofonix/wrappers/apa_product.rb, line 161
def bic_subjects
  subjects = product.subjects.select { |sub| sub.subject_scheme_id.to_i == 12 }
  subjects.collect { |sub| sub.subject_code}
end
bisac_subjects() click to toggle source

return an array of BISAC subjects for this title

# File lib/cacofonix/wrappers/apa_product.rb, line 172
def bisac_subjects
  subjects = product.subjects.select { |sub| sub.subject_scheme_id.to_i == 10 }
  subjects.collect { |sub| sub.subject_code}
end
contributors() click to toggle source

retrieve an array of all contributors

# File lib/cacofonix/wrappers/apa_product.rb, line 144
def contributors
  product.contributors.collect { |contrib| contrib.person_name_inverted || contrib.person_name}
end
cover_url() click to toggle source

retrieve the url to the product cover image

# File lib/cacofonix/wrappers/apa_product.rb, line 183
def cover_url
  media_file(4).try(:media_file_link)
end
cover_url=(url) click to toggle source

set the url to the product cover image

# File lib/cacofonix/wrappers/apa_product.rb, line 188
def cover_url=(url)
  # 4 - cover image
  # 1 - URI
  media_file_set(4,1,url)
end
cover_url_hq() click to toggle source

retrieve the url to the high quality product cover image

# File lib/cacofonix/wrappers/apa_product.rb, line 195
def cover_url_hq
  media_file(6).try(:media_file_link)
end
cover_url_hq=(url) click to toggle source

set the url to the high quality product cover image

# File lib/cacofonix/wrappers/apa_product.rb, line 200
def cover_url_hq=(url)
  # 6 - hq cover image
  # 1 - URI
  media_file_set(6,1,url)
end
ean() click to toggle source

retrieve the current EAN

# File lib/cacofonix/wrappers/apa_product.rb, line 28
def ean
  identifier(3).try(:id_value)
end
ean=(isbn) click to toggle source

set a new EAN

# File lib/cacofonix/wrappers/apa_product.rb, line 33
def ean=(isbn)
  identifier_set(3, isbn)
end
height() click to toggle source

retrieve the height of the product

If APAProduct#measurement_system is metric, these will be in mm, otherwise they will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 449
def height
  # TODO: auto unit conversion
  measurement(1).try(:measurement)
end
height=(value) click to toggle source

set the height of the book

If APAProduct#measurement_system is metric, this should be in mm, otherwise it will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 459
def height=(value)
  if measurement_system == :metric
    measurement_set(1,value, "mm")
  elsif measurement_system == :imperial
    measurement_set(1,value, "in")
  end
end
imprint() click to toggle source

retrieve the imprint

# File lib/cacofonix/wrappers/apa_product.rb, line 249
def imprint
  composite = product.imprints.first
  composite ? composite.imprint_name : nil
end
imprint=(str) click to toggle source

set a new imprint

# File lib/cacofonix/wrappers/apa_product.rb, line 255
def imprint=(str)
  composite = product.imprints.first
  if composite.nil?
    composite =  Cacofonix::Imprint.new
    product.imprints << composite
  end
  composite.imprint_name = str
end
isbn10() click to toggle source

retrieve the current ISBN 10

# File lib/cacofonix/wrappers/apa_product.rb, line 48
def isbn10
  identifier(2).try(:id_value)
end
isbn10=(isbn) click to toggle source

set a new ISBN 10

# File lib/cacofonix/wrappers/apa_product.rb, line 53
def isbn10=(isbn)
  identifier_set(2, isbn)
end
isbn13() click to toggle source

retrieve the current ISBN 13

# File lib/cacofonix/wrappers/apa_product.rb, line 58
def isbn13
  identifier(15).try(:id_value)
end
isbn13=(isbn) click to toggle source

set a new ISBN 13

# File lib/cacofonix/wrappers/apa_product.rb, line 63
def isbn13=(isbn)
  identifier_set(15, isbn)
end
long_description() click to toggle source

retrieve the long description

# File lib/cacofonix/wrappers/apa_product.rb, line 239
def long_description
  other_text(3).try(:text)
end
long_description=(t) click to toggle source

set the long description

# File lib/cacofonix/wrappers/apa_product.rb, line 244
def long_description=(t)
  other_text_set(3,t)
end
main_description() click to toggle source

retrieve the main description

# File lib/cacofonix/wrappers/apa_product.rb, line 219
def main_description
  other_text(1).try(:text)
end
main_description=(t) click to toggle source

set the main description

# File lib/cacofonix/wrappers/apa_product.rb, line 224
def main_description=(t)
  other_text_set(1,t)
end
market_country() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 551
def market_country
  reps = product.market_representations.first
  return nil if reps.nil?
  reps.market_country
end
market_country=(value) click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 557
def market_country=(value)
  reps = product.market_representations.first
  if reps.nil?
    reps = Cacofonix::MarketRepresentation.new
    product.market_representations << reps
  end
  reps.market_country = value.to_s
end
market_publishing_status() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 566
def market_publishing_status
  reps = product.market_representations.first
  return nil if reps.nil?
  reps.market_publishing_status
end
market_publishing_status=(value) click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 572
def market_publishing_status=(value)
  reps = product.market_representations.first
  if reps.nil?
    reps = Cacofonix::MarketRepresentation.new
    product.market_representations << reps
  end
  reps.market_publishing_status = value.to_i
end
measurement_system() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 15
def measurement_system
  @measurement_system ||= :metric
end
measurement_system=(value) click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 19
def measurement_system=(value)
  if value == :metric || value == :imperial
    @measurement_system = value
  else
    raise ArgumentError, "#{value} is not a recognised measurement system"
  end
end
on_hand() click to toggle source

retrieve the number in stock

# File lib/cacofonix/wrappers/apa_product.rb, line 363
def on_hand
  supply = find_or_create_supply_detail
  composite = supply.stock.first
  if composite.nil?
    composite = Cacofonix::Stock.new
    supply.stock << composite
  end
  composite.on_hand
end
on_hand=(num) click to toggle source

set a new in stock quantity

# File lib/cacofonix/wrappers/apa_product.rb, line 374
def on_hand=(num)
  supply = find_or_create_supply_detail
  composite = supply.stock.first
  if composite.nil?
    composite = Cacofonix::Stock.new
    supply.stock << composite
  end
  composite.on_hand = num
end
on_order() click to toggle source

retrieve the number on order

# File lib/cacofonix/wrappers/apa_product.rb, line 385
def on_order
  supply = find_or_create_supply_detail
  composite = supply.stock.first
  if composite.nil?
    composite = Cacofonix::Stock.new
    supply.stock << composite
  end
  composite.on_order
end
on_order=(num) click to toggle source

set a new on order quantity

# File lib/cacofonix/wrappers/apa_product.rb, line 396
def on_order=(num)
  supply = find_or_create_supply_detail
  composite = supply.stock.first
  if composite.nil?
    composite = Cacofonix::Stock.new
    supply.stock << composite
  end
  composite.on_order = num
end
pack_quantity() click to toggle source

retrieve the supplier phone number

# File lib/cacofonix/wrappers/apa_product.rb, line 407
def pack_quantity
  composite = product.supply_details.first
  composite.nil? ? nil : composite.pack_quantity
end
pack_quantity=(val) click to toggle source

set a new supplier phone number

# File lib/cacofonix/wrappers/apa_product.rb, line 413
def pack_quantity=(val)
  composite = find_or_create_supply_detail
  composite.pack_quantity = val.to_i
end
price() click to toggle source

just get the first price we can find, regardless of the type. useful as a backup for reading files from that don't contain a type

# File lib/cacofonix/wrappers/apa_product.rb, line 440
def price
  price_get(nil).try(:price_amount)
end
product_availability() click to toggle source

retrieve the product availability code

# File lib/cacofonix/wrappers/apa_product.rb, line 351
def product_availability
  composite = product.supply_details.first
  composite.nil? ? nil : composite.product_availability
end
product_availability=(num) click to toggle source

set a new product availability

# File lib/cacofonix/wrappers/apa_product.rb, line 357
def product_availability=(num)
  composite = find_or_create_supply_detail
  composite.product_availability = num
end
proprietary_id() click to toggle source

retrieve the proprietary ID

# File lib/cacofonix/wrappers/apa_product.rb, line 38
def proprietary_id
  identifier(1).tr(:id_value)
end
proprietary_id=(isbn) click to toggle source

set a new proprietary ID

# File lib/cacofonix/wrappers/apa_product.rb, line 43
def proprietary_id=(isbn)
  identifier_set(1, isbn)
end
publisher() click to toggle source

retrieve the publisher

# File lib/cacofonix/wrappers/apa_product.rb, line 265
def publisher
  publisher_get(1).try(:publisher_name)
end
publisher=(str) click to toggle source

set a new publisher

# File lib/cacofonix/wrappers/apa_product.rb, line 270
def publisher=(str)
  publisher_set(1, str)
end
publisher_website() click to toggle source

retrieve the current publisher website for this particular product

# File lib/cacofonix/wrappers/apa_product.rb, line 124
def publisher_website
  website(2).try(:website_link)
end
publisher_website=(str) click to toggle source

set a new publisher website for this particular product

# File lib/cacofonix/wrappers/apa_product.rb, line 129
def publisher_website=(str)
  website_set(2, str)
end
rrp_exc_sales_tax() click to toggle source

retrieve the rrp excluding any sales tax

# File lib/cacofonix/wrappers/apa_product.rb, line 419
def rrp_exc_sales_tax
  price_get(1).try(:price_amount)
end
rrp_exc_sales_tax=(num) click to toggle source

set the rrp excluding any sales tax

# File lib/cacofonix/wrappers/apa_product.rb, line 424
def rrp_exc_sales_tax=(num)
  price_set(1, num)
end
rrp_inc_sales_tax() click to toggle source

retrieve the rrp including any sales tax

# File lib/cacofonix/wrappers/apa_product.rb, line 429
def rrp_inc_sales_tax
  price_get(2).try(:price_amount)
end
rrp_inc_sales_tax=(num) click to toggle source

set the rrp including any sales tax

# File lib/cacofonix/wrappers/apa_product.rb, line 434
def rrp_inc_sales_tax=(num)
  price_set(2, num)
end
sales_restriction_type() click to toggle source

retrieve the sales restriction type

# File lib/cacofonix/wrappers/apa_product.rb, line 275
def sales_restriction_type
  composite = product.sales_restrictions.first
  composite.nil? ? nil : composite.imprint_name
end
sales_restriction_type=(type) click to toggle source

set a new sales restriction type

# File lib/cacofonix/wrappers/apa_product.rb, line 281
def sales_restriction_type=(type)
  composite = product.sales_restrictions.first
  if composite.nil?
    composite =  Cacofonix::SalesRestriction.new
    product.sales_restrictions << composite
  end
  composite.sales_restriction_type = type
end
series() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 109
def series
  composite = product.series.first
  composite.try(:title_of_series)
end
series=(val) click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 114
def series=(val)
  composite = product.series.first
  if composite.nil?
    composite =  Cacofonix::Series.new
    product.series << composite
  end
  composite.title_of_series = val.to_s
end
short_description() click to toggle source

retrieve the short description

# File lib/cacofonix/wrappers/apa_product.rb, line 229
def short_description
  other_text(2).try(:text)
end
short_description=(t) click to toggle source

set the short description

# File lib/cacofonix/wrappers/apa_product.rb, line 234
def short_description=(t)
  other_text_set(2,t)
end
subtitle() click to toggle source

retrieve the current subtitle

# File lib/cacofonix/wrappers/apa_product.rb, line 89
def subtitle
  composite = product.titles.first
  if composite.nil?
    nil
  else
    composite.subtitle
  end
end
subtitle=(str) click to toggle source

set a new subtitle

# File lib/cacofonix/wrappers/apa_product.rb, line 99
def subtitle=(str)
  composite = product.titles.first
  if composite.nil?
    composite =  Cacofonix::Title.new
    composite.title_type = 1
    product.titles << composite
  end
  composite.subtitle = str
end
supplier_email() click to toggle source

retrieve the supplier email address

# File lib/cacofonix/wrappers/apa_product.rb, line 327
def supplier_email
  composite = product.supply_details.first
  composite.nil? ? nil : composite.email_address
end
supplier_email=(str) click to toggle source

set a new supplier email address

# File lib/cacofonix/wrappers/apa_product.rb, line 333
def supplier_email=(str)
  composite = find_or_create_supply_detail
  composite.email_address = str
end
supplier_fax() click to toggle source

retrieve the supplier fax number

# File lib/cacofonix/wrappers/apa_product.rb, line 315
def supplier_fax
  composite = product.supply_details.first
  composite.nil? ? nil : composite.fax_number
end
supplier_fax=(str) click to toggle source

set a new supplier fax number

# File lib/cacofonix/wrappers/apa_product.rb, line 321
def supplier_fax=(str)
  composite = find_or_create_supply_detail
  composite.fax_number = str
end
supplier_name() click to toggle source

retrieve the supplier name

# File lib/cacofonix/wrappers/apa_product.rb, line 291
def supplier_name
  composite = product.supply_details.first
  composite.nil? ? nil : composite.supplier_name
end
supplier_name=(str) click to toggle source

set a new supplier name

# File lib/cacofonix/wrappers/apa_product.rb, line 297
def supplier_name=(str)
  composite = find_or_create_supply_detail
  composite.supplier_name = str
end
supplier_phone() click to toggle source

retrieve the supplier phone number

# File lib/cacofonix/wrappers/apa_product.rb, line 303
def supplier_phone
  composite = product.supply_details.first
  composite.nil? ? nil : composite.telephone_number
end
supplier_phone=(str) click to toggle source

set a new supplier phone number

# File lib/cacofonix/wrappers/apa_product.rb, line 309
def supplier_phone=(str)
  composite = find_or_create_supply_detail
  composite.telephone_number = str
end
supplier_website() click to toggle source

retrieve the current supplier website for this particular product

# File lib/cacofonix/wrappers/apa_product.rb, line 134
def supplier_website
  website(12).try(:website_link)
end
supplier_website=(str) click to toggle source

set a new supplier website for this particular product

# File lib/cacofonix/wrappers/apa_product.rb, line 139
def supplier_website=(str)
  website_set(12, str)
end
supply_country() click to toggle source

retrieve the supply country code

# File lib/cacofonix/wrappers/apa_product.rb, line 339
def supply_country
  composite = product.supply_details.first
  composite.nil? ? nil : composite.supply_to_country
end
supply_country=(str) click to toggle source

set a new supply country code

# File lib/cacofonix/wrappers/apa_product.rb, line 345
def supply_country=(str)
  composite = find_or_create_supply_detail
  composite.supply_to_country = str
end
thickness() click to toggle source

retrieve the thickness of the product

If APAProduct#measurement_system is metric, these will be in mm, otherwise they will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 518
def thickness
  # TODO: auto unit conversion
  measurement(3).try(:measurement)
end
thickness=(value) click to toggle source

set the thickness of the product

If APAProduct#measurement_system is metric, this should be in mm, otherwise it will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 528
def thickness=(value)
  if measurement_system == :metric
    measurement_set(3,value, "mm")
  elsif measurement_system == :imperial
    measurement_set(3,value, "in")
  end
end
thumbnail_url() click to toggle source

retrieve the url to the product thumbnail

# File lib/cacofonix/wrappers/apa_product.rb, line 207
def thumbnail_url
  media_file(7).try(:media_file_link)
end
thumbnail_url=(url) click to toggle source

set the url to the product cover image

# File lib/cacofonix/wrappers/apa_product.rb, line 212
def thumbnail_url=(url)
  # 7 - thumbnail image
  # 1 - URI
  media_file_set(7,1,url)
end
title() click to toggle source

retrieve the current title

# File lib/cacofonix/wrappers/apa_product.rb, line 68
def title
  composite = product.titles.first
  if composite.nil?
    nil
  else
    composite.title_text || composite.title_without_prefix
  end
end
title=(str) click to toggle source

set a new title

# File lib/cacofonix/wrappers/apa_product.rb, line 78
def title=(str)
  composite = product.titles.first
  if composite.nil?
    composite =  Cacofonix::Title.new
    composite.title_type = 1
    product.titles << composite
  end
  composite.title_text = str
end
weight() click to toggle source

retrieve the weight of the product

If APAProduct#measurement_system is metric, these will be in grams, otherwise they will be in ounces.

# File lib/cacofonix/wrappers/apa_product.rb, line 495
def weight
  # TODO: auto unit conversion
  measurement(8).try(:measurement)
end
weight=(value) click to toggle source

set the weight of the product

If APAProduct#measurement_system is metric, this should be in grams, otherwise it will be in ounces.

# File lib/cacofonix/wrappers/apa_product.rb, line 505
def weight=(value)
  if measurement_system == :metric
    measurement_set(8,value, "gr")
  elsif measurement_system == :imperial
    measurement_set(8,value, "oz")
  end
end
width() click to toggle source

retrieve the width of the product

If APAProduct#measurement_system is metric, these will be in mm, otherwise they will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 472
def width
  # TODO: auto unit conversion
  measurement(2).try(:measurement)
end
width=(value) click to toggle source

set the width of the product

If APAProduct#measurement_system is metric, this should be in mm, otherwise it will be in inches.

# File lib/cacofonix/wrappers/apa_product.rb, line 482
def width=(value)
  if measurement_system == :metric
    measurement_set(2,value, "mm")
  elsif measurement_system == :imperial
    measurement_set(2,value, "in")
  end
end

Private Instance Methods

add_subject(str, type = "12") click to toggle source

add a new subject to this product str should be the subject code type should be the code for the subject scheme you're using. See ONIX codelist 27. 12 is BIC

# File lib/cacofonix/wrappers/apa_product.rb, line 587
def add_subject(str, type = "12")
  subject = ::Cacofonix::Subject.new
  subject.subject_scheme_id = type.to_i
  subject.subject_code = str
  product.subjects << subject
end
find_or_create_supply_detail() click to toggle source
# File lib/cacofonix/wrappers/apa_product.rb, line 594
def find_or_create_supply_detail
  composite = product.supply_details.first
  if composite.nil?
    composite =  Cacofonix::SupplyDetail.new
    product.supply_details << composite
  end
  composite
end
identifier(type) click to toggle source

retrieve the value of a particular ID

# File lib/cacofonix/wrappers/apa_product.rb, line 604
def identifier(type)
  product.product_identifiers.find { |id| id.product_id_type == type }
end
identifier_set(type, value) click to toggle source

set the value of a particular ID

# File lib/cacofonix/wrappers/apa_product.rb, line 609
def identifier_set(type, value)
  isbn_id = identifier(type)

  # create a new isbn record if we need to
  if isbn_id.nil?
    isbn_id = Cacofonix::ProductIdentifier.new
    isbn_id.product_id_type = type
    product.product_identifiers << isbn_id
  end

  isbn_id.id_value = value
end
measurement(type) click to toggle source

retrieve the value of a particular measurement

# File lib/cacofonix/wrappers/apa_product.rb, line 623
def measurement(type)
  product.measurements.find { |m| m.measure_type_code == type }
end
measurement_set(type, value, unit) click to toggle source

set the value of a particular measurement

# File lib/cacofonix/wrappers/apa_product.rb, line 628
def measurement_set(type, value, unit)
  measure = measurement(type)

  # create a new isbn record if we need to
  if measure.nil?
    measure = Cacofonix::Measure.new
    measure.measure_type_code = type
    product.measurements << measure
  end

  # store the new value
  measure.measurement = value
  measure.measure_unit_code = unit.to_s
end
media_file(type) click to toggle source

retrieve the value of a particular media file

# File lib/cacofonix/wrappers/apa_product.rb, line 644
def media_file(type)
  product.media_files.find { |m| m.media_file_type_code == type }
end
media_file_set(type, link_type, value) click to toggle source

set the value of a particular ID

# File lib/cacofonix/wrappers/apa_product.rb, line 649
def media_file_set(type, link_type, value)
  media = media_file(type)

  # create a new isbn record if we need to
  if media.nil?
    media = Cacofonix::MediaFile.new
    media.media_file_type_code = type
    media.media_file_link_type_code = link_type
    product.media_files << media
  end

  # store the new value
  media.media_file_link = value.to_s
end
other_text(type) click to toggle source

retrieve the value of a particular other text value

# File lib/cacofonix/wrappers/apa_product.rb, line 711
def other_text(type)
  product.text.find { |t| t.text_type_code == type }
end
other_text_set(type, value) click to toggle source

set the value of a particular other text value

# File lib/cacofonix/wrappers/apa_product.rb, line 716
def other_text_set(type, value)
  text = other_text(type)

  if text.nil?
    text = Cacofonix::OtherText.new
    text.text_type_code = type
    product.text << text
  end

  # store the new value
  text.text = value.to_s
end
price_get(type) click to toggle source

retrieve the value of a particular price

# File lib/cacofonix/wrappers/apa_product.rb, line 665
def price_get(type)
  supply = find_or_create_supply_detail
  if type.nil?
    supply.prices.first
  else
    supply.prices.find { |p| p.price_type_code == type }
  end
end
price_set(type, num) click to toggle source

set the value of a particular price

# File lib/cacofonix/wrappers/apa_product.rb, line 675
def price_set(type, num)
  p = price_get(type)

  # create a new isbn record if we need to
  if p.nil?
    supply = find_or_create_supply_detail
    p = Cacofonix::Price.new
    p.price_type_code = type
    supply.prices << p
  end

  # store the new value
  p.price_amount = num
end
publisher_get(type) click to toggle source

retrieve the value of a particular publisher

# File lib/cacofonix/wrappers/apa_product.rb, line 691
def publisher_get(type)
  product.publishers.find { |pub| pub.publishing_role == type }
end
publisher_set(type, value) click to toggle source

set the value of a particular ID

# File lib/cacofonix/wrappers/apa_product.rb, line 696
def publisher_set(type, value)
  pub = publisher_get(type)

  # create a new isbn record if we need to
  if pub.nil?
    pub = Cacofonix::Publisher.new
    pub.publishing_role = type
    product.publishers << pub
  end

  # store the new value
  pub.publisher_name = value.to_s
end
website(type) click to toggle source

retrieve the value of a particular website

# File lib/cacofonix/wrappers/apa_product.rb, line 730
def website(type)
  product.websites.find { |site| site.website_role == type }
end
website_set(type, value) click to toggle source

set the value of a particular website

# File lib/cacofonix/wrappers/apa_product.rb, line 735
def website_set(type, value)
  site = website(type)

  # create a new website record if we need to
  if site.nil?
    site = Cacofonix::Website.new
    site.website_role = type
    product.websites << site
  end

  site.website_link = value.to_s
end