public Tuple <Byte[], string> DownloadViaParentWS(string id, string parentId, string parentApplication, string parentSchemaId) { // Get the parent entity executing a FindById operation in the respective WS var user = SecurityFacade.CurrentUser(); var applicationMetadata = MetadataProvider .Application(parentApplication) .ApplyPolicies(new ApplicationMetadataSchemaKey(parentSchemaId), user, ClientPlatform.Web); var response = _dataSetProvider.LookupAsBaseDataSet(parentApplication).Execute(applicationMetadata, new JObject(), parentId, OperationConstants.CRUD_FIND_BY_ID); var parent = response.ResultObject; if (parent != null) { var attachments = r.GetProperty(parent, "DOCLINKS") as IEnumerable; foreach (var attachment in attachments) { var attachmentId = w.GetRealValue(attachment, "DOCINFOID").ToString(); if (id.Equals(attachmentId)) { var fileBytes = w.GetRealValue(attachment, "DOCUMENTDATA") as byte[]; var fileName = BuildFileName(w.GetRealValue(attachment, "URLNAME") as String); return(Tuple.Create(fileBytes, fileName)); } } } return(null); }
public SynchronizationResultDto SyncData(SynchronizationRequestDto synchronizationRequest) { //TODO> the method should return only the fields //specified in the metadata, and not all entities //attributes. var user = SecurityFacade.CurrentUser(); if (null == user) { throw new HttpResponseException(HttpStatusCode.Unauthorized); } var syncResult = new SynchronizationResultDto(); foreach (var application in synchronizationRequest.Applications) { var applicationMetadata = MetadataProvider .Application(application.appName) .ApplyPolicies(ApplicationMetadataSchemaKey.GetSyncInstance(), user, ClientPlatform.Mobile); var syncAppData = _dataSetProvider.LookupAsBaseDataSet(application.appName) .Sync(applicationMetadata, application); if (!application.FetchMetadata) { //used to reduce the amount of data sent syncAppData.Metadata = null; } syncResult.SynchronizationData.Add(syncAppData); } return(syncResult); }
public IApplicationResponse RedirectToNextSchema(ApplicationMetadata applicationMetadata, string operation, string id, ClientPlatform platform, ApplicationMetadataSchemaKey currentschemaKey, ApplicationMetadataSchemaKey nextSchemaKey, bool maximoMocked = false) { var applicationName = applicationMetadata.Name; if (nextSchemaKey == null) { if (HasActionRedirectionDefinedByProperties(applicationMetadata.Schema, operation)) { return(ActionRedirection(applicationMetadata.Schema, operation)); } nextSchemaKey = ResolveNextSchemaKey(operation, currentschemaKey, platform, applicationMetadata); } // var applicationName = currentMetadata.Name; var metadata = MetadataProvider.Application(applicationName); var resultSchema = metadata.Schema(nextSchemaKey, true); var user = SecurityFacade.CurrentUser(); var nextMetadata = metadata.ApplyPolicies(nextSchemaKey, user, ClientPlatform.Web); var dataSet = _dataSetProvider.LookupAsBaseDataSet(applicationName); if (resultSchema.Stereotype == SchemaStereotype.Detail) { if (maximoMocked && id == null) { return(mockUtils.GetMockedDataMap(applicationName, resultSchema, nextMetadata)); } var detailRequest = new DetailRequest(nextSchemaKey, null) { Id = id }; detailRequest.CompositionsToFetch = operation != OperationConstants.CRUD_CREATE ? "#all" : null; var response = dataSet.Get(nextMetadata, SecurityFacade.CurrentUser(), detailRequest); return(response); } if (resultSchema.Stereotype == SchemaStereotype.List) { var paginatedSearchRequestDto = PaginatedSearchRequestDto.DefaultInstance(resultSchema); return(dataSet.Get(nextMetadata, user, new DataRequestAdapter(paginatedSearchRequestDto))); } throw new NotImplementedException("missing implementation for this kind of schema redirection"); }