Skip to content
Snippets Groups Projects
Commit a9b53c18 authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

[Projekt: Entwicklung - Neon][TicketNr.: 1066467][Fehler Importer_lib für iAttribute und iComm]

parent 83ff4d9f
No related branches found
No related tags found
No related merge requests found
......@@ -184,19 +184,29 @@ function iAttribute(pObject)
if (value && objectId)
{
id = newSelect(ab_attributeRelationId, alias).from(ab_attributeRelation).where(attrRel_ab_attribute_id, attributeId)
.and(object_rowId, objectId).and(attrRel_object_type, objectType).cell();
if (id == "" || id == null)
var exisingAttrRelation = newSelect([ab_attributeRelationId, valueColumn], alias)
.from(ab_attributeRelation)
.where(attrRel_ab_attribute_id, attributeId)
.and(object_rowId, objectId)
.and(attrRel_object_type, objectType)
.arrayRow();
if (exisingAttrRelation.length == 0)
{
columns = [ab_attributeRelationId, attrRel_ab_attribute_id, attrRel_object_type, object_rowId, valueColumn];
values = [util.getNewUUID(), attributeId, objectType, objectId, value];
this.insertData(ab_attributeRelation, columns, null, values, alias);
}
else if (this.Config.ImportCommand.indexOf("update") != -1)
}
else
{
cond = ab_attributeRelationId + " = '" + id + "'";
this.updateData(ab_attributeRelation, [valueColumn], null, [value], cond, alias);
var existingValue;
[id, existingValue] = exisingAttrRelation;
//new value has to differ from the old (existing) value to prevent unneccesary updates
if (this.Config.ImportCommand.indexOf("update") != -1 && value != null && value.toString() != existingValue)
{
cond = ab_attributeRelationId + " = '" + id + "'";
this.updateData(ab_attributeRelation, [valueColumn], null, [value], cond, alias);
}
}
}
}
......@@ -358,23 +368,36 @@ function iComm(pObject) {
var contact = this.InputRecord[pObject.ContactID];
var standard = "0";
if(address == undefined) address = this.resolveSymbol(pObject, pObject.address);
if(medium == undefined) medium = this.resolveSymbol(pObject, pObject.medium);
if(address == undefined) address = this.resolveSymbol(pObject, pObject.Address);
if(medium == undefined) medium = this.resolveSymbol(pObject, pObject.Medium);
if(contact == undefined) contact = this.resolveSymbol(pObject, pObject.ContactID);
if(pObject.Standard) standard = "1";
if(!address || !medium || !contact) return true;
var sql = "select " + this.getColumnCase("communicationid") + " from " + this.getTableCase("communication")
var sql = "select " + this.getColumnCase("communicationid") + ", " + this.getColumnCase("addr") + " from " + this.getTableCase("communication")
+" where " + this.getColumnCase("contact_id") + " = ? and " + this.getColumnCase("medium_id") + " = ? and "
+ this.getColumnCase("isstandard") + " = ? and " + this.getColumnCase("addr") + " = ?"
var id = db.cell([sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR], //TODO: define types dynamically and not hardcoded
[standard, SQLTYPES.SMALLINT], [address, SQLTYPES.VARCHAR]]], this.Config.AliasTo);
if (id == "" || id == null) {
+ this.getColumnCase("isstandard") + " = ?";
var existingData = db.array(db.ROW, [sql, [[contact, SQLTYPES.CHAR], [medium, SQLTYPES.CHAR], //TODO: define types dynamically and not hardcoded
[standard, SQLTYPES.SMALLINT]]], this.Config.AliasTo, 0, this.getConfiguredTimeout());
if (existingData.length == 0)
{
var columns = [this.getColumnCase("communicationid"), this.getColumnCase("addr"),
this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("isstandard")];
this.getColumnCase("medium_id"), this.getColumnCase("contact_id"), this.getColumnCase("isstandard")];
this.insertData(this.getTableCase("communication"), columns, null, [util.getNewUUID(), address, medium, contact, standard], this.Config.AliasTo);
}
}
else
{
var existingId = existingData[0];
var existingAddress = existingData[1];
if (address != existingAddress)
{
var cond = this.getColumnCase("communicationid") + " = '" + existingId + "'";
this.updateData(this.getTableCase("communication"), [this.getColumnCase("addr")], null, [address], cond, this.Config.AliasTo);
}
}
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment