private Releaseability MakeSupplementalAssesment(ISupplementalExtractionResults supplementalExtractionResults) { var extractedObject = _repositoryLocator.GetArbitraryDatabaseObject( supplementalExtractionResults.ReferencedObjectRepositoryType, supplementalExtractionResults.ReferencedObjectType, supplementalExtractionResults.ReferencedObjectID) as INamed; if (extractedObject == null) { return(Releaseability.Undefined); } if (extractedObject is SupportingSQLTable) { if ((extractedObject as SupportingSQLTable).SQL != supplementalExtractionResults.SQLExecuted) { return(Releaseability.ExtractionSQLDesynchronisation); } } var finalAssessment = GetSupplementalSpecificAssessment(supplementalExtractionResults); if (finalAssessment == Releaseability.Undefined) { return(extractedObject.Name != supplementalExtractionResults.ExtractedName ? Releaseability.ExtractionSQLDesynchronisation : Releaseability.Releaseable); } return(finalAssessment); }
/// <summary> /// Fetches the listed objects out of the collection section of a persistence string by fetching the listed ObjectType by ID from the RepoType /// </summary> /// <param name="allObjectsString">A string with a list of objects ID's, should have the format [RepoType:ObjectType:ID,RepoType:ObjectType:ID]</param> /// <param name="repositoryLocator"></param> /// <returns></returns> public List <IMapsDirectlyToDatabaseTable> GetObjectCollectionFromPersistString(string allObjectsString, IRDMPPlatformRepositoryServiceLocator repositoryLocator) { var toReturn = new List <IMapsDirectlyToDatabaseTable>(); allObjectsString = allObjectsString.Trim(CollectionStartDelimiter.ToCharArray()[0], CollectionEndDelimiter.ToCharArray()[0]); var objectStrings = allObjectsString.Split(new[] { CollectionObjectSeparator }, StringSplitOptions.RemoveEmptyEntries); foreach (string objectString in objectStrings) { var objectTokens = objectString.Split(Separator); if (objectTokens.Length != 3) { throw new PersistenceException("Could not figure out what database object to fetch because the list contained an item with an invalid number of tokens (" + objectTokens.Length + " tokens). The current object string is:" + Environment.NewLine + objectString); } var dbObj = repositoryLocator.GetArbitraryDatabaseObject(objectTokens[0], objectTokens[1], Int32.Parse(objectTokens[2])); if (dbObj != null) { toReturn.Add(dbObj); } else { throw new PersistenceException("DatabaseObject '" + objectString + "' has been deleted meaning IPersistableObjectCollection could not be properly created/populated"); } } return(toReturn); }
public DeserializeInstruction ShouldCreateSingleObjectControl(string persistString, IRDMPPlatformRepositoryServiceLocator repositoryLocator) { if (!persistString.StartsWith(PersistableSingleDatabaseObjectDockContent.Prefix)) { return(null); } //return Prefix + s + _control.GetType().Name + s + _databaseObject.Repository.GetType() + s + _databaseObject.GetType().Name + s + _databaseObject.ID; var tokens = persistString.Split(PersistStringHelper.Separator); if (tokens.Length != 5) { throw new PersistenceException("Unexpected number of tokens (" + tokens.Length + ") for Persistence of Type " + PersistableSingleDatabaseObjectDockContent.Prefix); } Type controlType = GetTypeByName(tokens[1], typeof(Control), repositoryLocator); IMapsDirectlyToDatabaseTable o = repositoryLocator.GetArbitraryDatabaseObject(tokens[2], tokens[3], int.Parse(tokens[4])); return(new DeserializeInstruction(controlType, o)); }
/// <summary> /// Deserializes the given persistence string (created by <see cref="GetPersistenceString"/>) into an actual database object. The /// <paramref name="persistenceString"/> is a pointer (ID / SharingUI) of the object not a value serialization. If you want to export the /// definition use <see cref="ShareDefinition"/> or Gatherer instead /// </summary> /// <param name="persistenceString"></param> /// <returns></returns> public IMapsDirectlyToDatabaseTable GetObjectFromPersistenceString(string persistenceString) { if (string.IsNullOrWhiteSpace(persistenceString)) { return(null); } var elements = persistenceString.Split(new [] { PersistenceSeparator }, StringSplitOptions.None); if (elements.Length < 4) { throw new Exception("Malformed persistenceString:" + persistenceString); } //elements[0];//type name of the class we are fetching //elements[1]; //ID of the class //elements[2]; // Repository Type name //elements[3]; // SharingUI if it has one //if it has a sharing UID if (!string.IsNullOrWhiteSpace(elements[3])) { var localImport = GetExistingImport(elements[3]); //which was imported as a local object if (localImport != null) { return(localImport.GetReferencedObject(RepositoryLocator)); //get the local object } } //otherwise get the existing master object var o = RepositoryLocator.GetArbitraryDatabaseObject(elements[2], elements[0], int.Parse(elements[1])); if (o == null) { throw new Exception("Could not find object for persistenceString:" + persistenceString); } return(o); }
/// <summary> /// Returns the instance of the object referenced by this class or null if it no longer exists (e.g. has been deleted) /// </summary> /// <param name="repositoryLocator"></param> /// <returns></returns> public virtual IMapsDirectlyToDatabaseTable GetReferencedObject(IRDMPPlatformRepositoryServiceLocator repositoryLocator) { return(repositoryLocator.GetArbitraryDatabaseObject(ReferencedObjectRepositoryType, ReferencedObjectType, ReferencedObjectID)); }