app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-0.2.11 vs app/models/maestrano/connector/rails/concerns/entity.rb in maestrano-connector-rails-0.2.12
- old
+ new
@@ -116,11 +116,11 @@
if idmap && ((!idmap.to_external) || (idmap.last_push_to_external && idmap.last_push_to_external > entity['updated_at']))
Maestrano::Connector::Rails::ConnectorLogger.log('info', organization, "Discard Connec! #{self.connec_entity_name} : #{entity}")
nil
else
- {entity: self.map_to_external(entity, organization), idmap: idmap || Maestrano::Connector::Rails::IdMap.create(connec_id: entity['id'], connec_entity: self.connec_entity_name.downcase, organization_id: organization.id)}
+ {entity: self.map_to_external(entity, organization), idmap: idmap || Maestrano::Connector::Rails::IdMap.create(connec_id: entity['id'], connec_entity: self.connec_entity_name.downcase, organization_id: organization.id, name: object_name_from_connec_entity_hash(entity))}
end
end
# ----------------------------------------------
# External methods
@@ -187,11 +187,11 @@
external_entities.map!{|entity|
idmap = Maestrano::Connector::Rails::IdMap.find_by(external_id: self.get_id_from_external_entity_hash(entity), external_entity: self.external_entity_name.downcase, organization_id: organization.id)
# No idmap: creating one, nothing else to do
unless idmap
- next {entity: self.map_to_connec(entity, organization), idmap: Maestrano::Connector::Rails::IdMap.create(external_id: self.get_id_from_external_entity_hash(entity), external_entity: self.external_entity_name.downcase, organization_id: organization.id)}
+ next {entity: self.map_to_connec(entity, organization), idmap: Maestrano::Connector::Rails::IdMap.create(external_id: self.get_id_from_external_entity_hash(entity), external_entity: self.external_entity_name.downcase, organization_id: organization.id, name: self.object_name_from_external_entity_hash(entity))}
end
# Not pushing entity to Connec!
next nil unless idmap.to_connec
@@ -232,11 +232,11 @@
# ----------------------------------------------
# Entity specific methods
# Those methods need to be define in each entity
# ----------------------------------------------
-
+
# Entity name in Connec!
def connec_entity_name
raise "Not implemented"
end
@@ -245,8 +245,18 @@
raise "Not implemented"
end
# Entity Mapper Class
def mapper_class
+ raise "Not implemented"
+ end
+
+ # Return a string representing the object from a connec! entity hash
+ def object_name_from_connec_entity_hash(entity)
+ raise "Not implemented"
+ end
+
+ # Return a string representing the object from an external entity hash
+ def object_name_from_external_entity_hash(entity)
raise "Not implemented"
end
end
\ No newline at end of file