private static int mapFromUpdated( Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItem workItem, EnterpriseChangeRequest newEcr, String fieldName) { int noOfMappedChanged = 0; // TODO: For the "calculated" fields we have defined ourselves we know the // dependencies, but should be expressed more elegant than this. Also the // Ericsson.Defect.User.DisplayName is dependent on System.AssignedTo but // will not be updated - we "know" that ... if (fieldName.Equals(TFSMapper.TFS_OWNER)) { fieldName = TFSMapper.ERICSSON_DEFECT_USER_SIGNUM; } // Can be multiple ECR properties updated by one TFS field List <Property> props = props = AttributesMapper.getInstance().getNotifyProperties(fieldName); if (props != null && props.Count > 0) { foreach (Property prop in props) { if (prop.getNotifyChange() && TFSMapper.getInstance().setEcrValues(newEcr, prop.getKey(), workItem)) { noOfMappedChanged++; } } } return(noOfMappedChanged); }
private static bool initMapping(XElement config, String adapterHome) { try { attributeMappingFile = config.Element("attributeMappingFile").Attribute("name").Value; attributeMappingFile = replaceRelativePath(adapterHome, attributeMappingFile); handleConfigFileChange(ConfigFile.ATTRIBUTE_MAPPINGS, attributeMappingFile); if (!File.Exists(attributeMappingFile)) { LogMessage( String.Format("Failed to find attribute mapping file at: {0}. Exit.", attributeMappingFile), LoggingLevel.ERROR); return(false); } else if (!AttributesMapper.getInstance().Load(attributeMappingFile, false)) { // Logging of error in Load method return(false); } LogMessage("Attribute mapping file read: " + attributeMappingFile, LoggingLevel.INFO); customerMappingFile = config.Element("customerMappingFile").Attribute("name").Value; customerMappingFile = replaceRelativePath(adapterHome, customerMappingFile); handleConfigFileChange(ConfigFile.CUSTOMER_MAPPINGS, customerMappingFile); if (!File.Exists(customerMappingFile)) { LogMessage( String.Format("Failed to find customer mapping file at: {0}. Exit.", customerMappingFile), LoggingLevel.ERROR); return(false); } else if (!AttributesMapper.getInstance().Load(customerMappingFile, true)) { // Logging of error in Load method return(false); } LogMessage("Customer mapping file read: " + customerMappingFile, LoggingLevel.INFO); productMappingFile = config.Element("productMappingFile").Attribute("name").Value; productMappingFile = replaceRelativePath(adapterHome, productMappingFile); handleConfigFileChange(ConfigFile.PRODUCT_MAPPINGS, productMappingFile); if (!File.Exists(productMappingFile)) { LogMessage( String.Format("Failed to find product mapping file at: {0}. Exit.", productMappingFile), LoggingLevel.ERROR); return(false); } else if (!ProductMapper.getInstance().Load(productMappingFile)) { // Logging of error in Load method return(false); } LogMessage("Product mapping file read: " + productMappingFile, LoggingLevel.INFO); } catch (Exception e) { LogMessage( String.Format("Exception when loading a mapping file: {0}. Exit.", e.Message), LoggingLevel.ERROR); return(false); } return(true); }