public SimpleRacoonResponse LoadLDLFile(byte[] token, string[] LDLFileContent, string[] AbsolutePosContent, string graph) { Exception error = null; SimpleRacoonResponse res = new SimpleRacoonResponse(); Session currentSession; if (SessionStore.TryGetValidSession(token, out currentSession)) { try { LDLParser theParser = LDLParser.GetParser(); theParser.ParseText(LDLFileContent, AbsolutePosContent); IEnumerable <BOTripple> tripples = theParser.GetAsTripples(); List <InsertableTriple> toInsert = new List <InsertableTriple>(); foreach (BOTripple trip in tripples) { toInsert.Add(new InsertableTriple(trip)); } error = InsertTripple.InsertData(toInsert, graph, currentSession); } catch (Exception ex) { error = ex; } QueryExecution.SuccessResponse(res, error); } else { QueryExecution.SecurityFailureResponse(res); } return(res); }
public static string getDctmObjectId(IQueryService querySvc, Qualification qualification) { string result = string.Empty; PassthroughQuery passthroughQuery = new PassthroughQuery(); passthroughQuery.QueryString = "SELECT r_object_id FROM " + qualification.GetValueAsString(); passthroughQuery.Repositories = new List <string>(); passthroughQuery.Repositories.Add(DctmConfigurations.GetRepositoryName()); QueryExecution queryExecution = new QueryExecution(); queryExecution.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryExecution.MaxResultCount = 1; QueryResult queryResult = querySvc.Execute(passthroughQuery, queryExecution, null); if (queryResult.DataPackage.DataObjects != null && queryResult.DataPackage.DataObjects.Count > 0) { DataObject dataObj = queryResult.DataPackage.DataObjects[0]; result = ((ObjectId)dataObj.Identity.Value).Id; } return(result); }
/// <summary> /// Reperimento formato file documentum /// </summary> /// <param name="queryService"></param> /// <param name="mimeType"></param> /// <returns></returns> public static string getDctmFileFormat(IQueryService queryService, string fileExtension) { string fileFormat = string.Empty; PassthroughQuery passthroughQuery = new PassthroughQuery(); passthroughQuery.QueryString = string.Format("SELECT name FROM dm_format WHERE dos_extension = '{0}'", replaceInvalidFileExtension(fileExtension).ToLower()); passthroughQuery.Repositories = new List <string>(); passthroughQuery.Repositories.Add(DctmConfigurations.GetRepositoryName()); QueryExecution queryExecution = new QueryExecution(); queryExecution.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryExecution.MaxResultCount = 1; QueryResult queryResult = queryService.Execute(passthroughQuery, queryExecution, null); if (queryResult.DataPackage.DataObjects != null && queryResult.DataPackage.DataObjects.Count > 0) { DataObject dataObj = queryResult.DataPackage.DataObjects[0]; fileFormat = ((StringProperty)dataObj.Properties.Properties[0]).Value; } return(fileFormat); }
public void BasicPassthroughQuery() { PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select r_object_id, " + "object_name from dm_cabinet"; query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); Console.WriteLine("QueryId == " + query.QueryString); Console.WriteLine("CacheStrategyType == " + queryEx.CacheStrategyType); DataPackage resultDp = queryResult.DataPackage; List <DataObject> dataObjects = resultDp.DataObjects; Console.WriteLine("Total objects returned is: " + dataObjects.Count); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; String objectId = dObj.Identity.GetValueAsString(); String docName = docProperties.Get("object_name").GetValueAsString(); Console.WriteLine("Document " + objectId + " name is " + docName); } }
public static QueryExecutionStatisticsTable CreateFromExecutionResult(QueryExecution queryExecution) { var props = queryExecution.GetType() .GetProperties() .Where(pi => !_queryExecutionIgnoredPropertyNames.Contains(pi.Name)) .ToArray(); var dataTable = new QueryExecutionStatisticsTable() { PropertyInfos = props }; foreach (var prop in props) { dataTable.Columns.Add(new DataColumn(prop.Name, prop.PropertyType) { ReadOnly = true }); } dataTable.Columns.Add(new DataColumn(_errorColumnHeader, typeof(bool)) { ReadOnly = true }); dataTable.AddRow(queryExecution); return(dataTable); }
public QueryResult SimplePassthroughQuery() { QueryResult queryResult; string queryString = "select distinct r_object_id from dm_document order by r_object_id "; int startingIndex = 0; int maxResults = 60; int maxResultsPerSource = 20; PassthroughQuery q = new PassthroughQuery(); q.QueryString = queryString; q.AddRepository(DefaultRepository); QueryExecution queryExec = new QueryExecution(startingIndex, maxResults, maxResultsPerSource); queryExec.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryResult = searchService.Execute(q, queryExec, null); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Console.WriteLine(repStatusInfo.ErrorTrace); throw new Exception("Query failed to return result."); } Console.WriteLine("Query returned result successfully."); DataPackage dp = queryResult.DataPackage; Console.WriteLine("DataPackage contains " + dp.DataObjects.Count + " objects."); foreach (DataObject dataObject in dp.DataObjects) { Console.WriteLine(dataObject.Identity.GetValueAsString()); } return queryResult; }
public SimpleRacoonResponse InsertTripleSimple(byte[] token, InsertableTriple[] DataToInsert, string graph) { Exception error = null; SimpleRacoonResponse res = new SimpleRacoonResponse(); if (DataToInsert.Length == 0) { res.AuthorisationOK = true;//we don't know this, but nor do we wish to trigger anything around dealing with aurthorisation problems res.Error = new ArgumentException("Must pass in some data to insert"); res.Status = false; return(res); } Session currentSession; if (SessionStore.TryGetValidSession(token, out currentSession)) { error = InsertData(DataToInsert, graph, currentSession); QueryExecution.SuccessResponse(res, error); } else { QueryExecution.SecurityFailureResponse(res); } return(res); }
/// <summary> /// Creates an Athena Query Metric from a QueryExecution /// </summary> /// <param name="queryExecution"></param> private AthenaQueryMetric(QueryExecution queryExecution) { this.QueryExecutionId = queryExecution.QueryExecutionId; this.StatementType = queryExecution.StatementType; this.DataScannedInBytes = queryExecution.Statistics.DataScannedInBytes; this.EngineExecutionTimeInMillis = queryExecution.Statistics.EngineExecutionTimeInMillis; this.CompletionDate = queryExecution.Status.CompletionDateTime.ToUniversalTime(); this.SubmissionDate = queryExecution.Status.SubmissionDateTime.ToUniversalTime(); this.Status = queryExecution.Status.State; this.Database = queryExecution.QueryExecutionContext.Database; this.Query = Convert.ToBase64String(Encoding.UTF8.GetBytes(queryExecution.Query)); this.OutputLocation = queryExecution.ResultConfiguration.OutputLocation; if (queryExecution.ResultConfiguration.EncryptionConfiguration != null) { this.EncryptionConfiguration = queryExecution.ResultConfiguration.EncryptionConfiguration.EncryptionOption.Value ?? String.Empty; this.KmsKey = queryExecution.ResultConfiguration.EncryptionConfiguration.KmsKey ?? String.Empty; } else { this.EncryptionConfiguration = String.Empty; this.KmsKey = String.Empty; } this.BillingPeriod = queryExecution.Status.SubmissionDateTime.ToUniversalTime().ToString("yyyy-MM-01"); }
private IList <QueryResults> ExecuteQuery(QueryDescriptor queryDescriptor, QueryExecution queryExecution) { using (var client = new DedsSearchServiceClient(this.searchEndpointConfigurationName)) { return(client.ExecuteQuery((Guid)queryDescriptor.Id, queryExecution)); } }
public Form1(string db, string server) { InitializeComponent(); q = new QueryExecution(db, server); richTextQuest.Font = new Font(FontFamily.GenericMonospace, 18, FontStyle.Regular); richTextBox1.Font = new Font(FontFamily.GenericMonospace, 18, FontStyle.Regular); richTextBox2.Font = new Font(FontFamily.GenericMonospace, 18, FontStyle.Regular); }
async static Task <List <Dictionary <String, String> > > getQueryExecution(IAmazonAthena client, String id) { List <Dictionary <String, String> > items = new List <Dictionary <String, String> >(); GetQueryExecutionResponse results = null; QueryExecution q = null; /* Declare query execution request object */ GetQueryExecutionRequest qReq = new GetQueryExecutionRequest() { QueryExecutionId = id }; /* Poll API to determine when the query completed */ do { results = await client.GetQueryExecutionAsync(qReq); q = results.QueryExecution; await Task.Delay(5000); //Wait for 5sec before polling again } while (q.Status.State == "RUNNING" || q.Status.State == "QUEUED"); Console.WriteLine("Data Scanned for {0}: {1} Bytes", id, q.Statistics.DataScannedInBytes); /* Declare query results request object */ GetQueryResultsRequest resReq = new GetQueryResultsRequest() { QueryExecutionId = id, MaxResults = 10 }; GetQueryResultsResponse resResp = null; /* Page through results and request additional pages if available */ do { resResp = await client.GetQueryResultsAsync(resReq); /* Loop over result set and create a dictionary with column name for key and data for value */ foreach (Row row in resResp.ResultSet.Rows) { Dictionary <String, String> dict = new Dictionary <String, String>(); for (var i = 0; i < resResp.ResultSet.ResultSetMetadata.ColumnInfo.Count; i++) { dict.Add(resResp.ResultSet.ResultSetMetadata.ColumnInfo[i].Name, row.Data[i].VarCharValue); } items.Add(dict); } if (resResp.NextToken != null) { resReq.NextToken = resResp.NextToken; } } while (resResp.NextToken != null); /* Return List of dictionary per row containing column name and value */ return(items); }
public static Exception InsertSingleTripleExec(string subj, string pred, string obj, string graph, Session currentSession) { Exception error; StringBuilder QueryBuilder = createQueryBuilder(graph); QueryBuilder.AppendFormat(" {0} {1} {2} ", subj, pred, obj); QueryBuilder.Append("} } "); QueryExecution.executeSPARQL(QueryBuilder.ToString(), Enumerable.Empty <IConvertToMiddlewareParam>(), currentSession, ParameterTypeEnum.NoExtraData, out error); return(error); }
//public IEnumerable<DocumentModel> SimplePassthroughQueryDocumentWithPath(string filename, string subject) //{ // List<DocumentModel> documentModels = new List<DocumentModel>(); // QueryResult queryResult; // try // { // string queryString = "select dm_document.r_object_id, dm_document.subject, dm_document.a_content_type,dm_document.object_name,dm_format.dos_extension from dm_document,dm_format where dm_document.a_content_type = dm_format.name"; // if ((!String.IsNullOrEmpty(filename)) && (!String.IsNullOrEmpty(subject))) // { // queryString = queryString + " and upper(object_name) like '%" + filename.ToUpper() + "%' and upper(subject) like '%" + subject.ToUpper() + "%'"; // } // if ((!String.IsNullOrEmpty(filename)) && (String.IsNullOrEmpty(subject))) // { // queryString = queryString + " and upper(object_name) like '%" + filename.ToUpper() + "%'"; // } // if ((String.IsNullOrEmpty(filename)) && (!String.IsNullOrEmpty(subject))) // { // queryString = queryString + " and upper(subject) like '%" + subject.ToUpper() + "%'"; // } // int startingIndex = 0; // int maxResults = 60; // int maxResultsPerSource = 20; // PassthroughQuery q = new PassthroughQuery(); // q.QueryString = queryString; // q.AddRepository(DefaultRepository); // QueryExecution queryExec = new QueryExecution(startingIndex, // maxResults, // maxResultsPerSource); // queryExec.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; // queryResult = searchService.Execute(q, queryExec, null); // QueryStatus queryStatus = queryResult.QueryStatus; // RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; // if (repStatusInfo.Status == Status.FAILURE) // { // // Console.WriteLine(repStatusInfo.ErrorTrace); // documentModels.Add(new DocumentModel() { ObjectId = "0", ObjectName = repStatusInfo.ErrorMessage, Subject = repStatusInfo.ErrorTrace }); // } // //Console.WriteLine("Query returned result successfully."); // DataPackage dp = queryResult.DataPackage; // //Console.WriteLine("DataPackage contains " + dp.DataObjects.Count + " objects."); // foreach (DataObject dObj in dp.DataObjects) // { // PropertySet docProperties = dObj.Properties; // String objectId = dObj.Identity.GetValueAsString(); // String docName = docProperties.Get("object_name").GetValueAsString(); // String Extension = docProperties.Get("dos_extension").GetValueAsString(); // string repName = dObj.Identity.RepositoryName; // string docsubject = docProperties.Get("subject").GetValueAsString(); // //Console.WriteLine("RepositoryName: " + repName + " ,Document: " + objectId + " ,Name:" + docName + " ,Subject:" + docsubject); // documentModels.Add(new DocumentModel() { ObjectId = objectId, ObjectName = docName+"."+Extension , Subject = docsubject }); // } // } // catch (Exception ex) // { // documentModels.Add(new DocumentModel() { ObjectId = "1", ObjectName = "SampleFile.txt", Subject = "This is a Sample" }); // } // return documentModels; //} public void SimpleStructuredQuery(String docName) { String repoName = DefaultRepository; Console.WriteLine("Called SimpleStructuredQuery - " + DefaultRepository); PropertyProfile propertyProfile = new PropertyProfile(); propertyProfile.FilterMode = PropertyFilterMode.IMPLIED; OperationOptions operationOptions = new OperationOptions(); operationOptions.Profiles.Add(propertyProfile); // Create query StructuredQuery q = new StructuredQuery(); q.AddRepository(repoName); q.ObjectType = "dm_document"; q.IsIncludeHidden = true; q.IsDatabaseSearch = true; ExpressionSet expressionSet = new ExpressionSet(); expressionSet.AddExpression(new PropertyExpression("object_name", Condition.CONTAINS, docName)); q.RootExpressionSet = expressionSet; // Execute Query int startingIndex = 0; int maxResults = 60; int maxResultsPerSource = 20; QueryExecution queryExec = new QueryExecution(startingIndex, maxResults, maxResultsPerSource); QueryResult queryResult = searchService.Execute(q, queryExec, operationOptions); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Console.WriteLine(repStatusInfo.ErrorTrace); throw new Exception("Query failed to return result."); } Console.WriteLine("Query returned result successfully."); // print results Console.WriteLine("DataPackage contains " + queryResult.DataObjects.Count + " objects."); foreach (DataObject dataObject in queryResult.DataObjects) { Console.WriteLine(dataObject.Identity.GetValueAsString()); } }
public SimpleRacoonResponse AddNewItem(byte[] token, string graphUri, string ItemURI, string superClassURI, string labelText, string description) { List <ParameterBase> InputParamList = new List <ParameterBase>() { new UriParameter("graph", new Uri(graphUri), ParameterDirection.In), new UriParameter("itemURI", new Uri(ItemURI), ParameterDirection.In), new UriParameter("superTypeURI", new Uri(superClassURI), ParameterDirection.In), new StringParameter("label", labelText, ParameterDirection.In), new StringParameter("description", description, ParameterDirection.In) }; return((SimpleRacoonResponse)QueryExecution.ExecuteQueryAllTypes(token, SprocNames.InsertClass, InputParamList, ParameterTypeEnum.NoExtraData)); }
public static Exception InsertData(IEnumerable <InsertableTriple> DataToInsert, string graph, Session currentSession) { Exception error; StringBuilder QueryBuilder = createQueryBuilder(graph); foreach (InsertableTriple tripple in DataToInsert) { QueryBuilder.AppendLine(tripple.ToSparqlLine(currentSession)); } QueryBuilder.Append("} } "); QueryExecution.executeSPARQL(QueryBuilder.ToString(), Enumerable.Empty <IConvertToMiddlewareParam>(), currentSession, ParameterTypeEnum.NoExtraData, out error); return(error); }
public void AddRow(QueryExecution queryExecution) { var row = NewRow(); foreach (var prop in PropertyInfos) { row[prop.Name] = prop.GetValue(queryExecution); } row[_errorColumnHeader] = queryExecution.ExecutionError != null; _queryExecutionMap.Add(row, queryExecution); Rows.Add(row); }
public QueryResult SimplePassthroughQueryDocument() { QueryResult queryResult; string queryString = "select r_object_id, object_name from eifx_deliverable_doc"; int startingIndex = 0; int maxResults = 60; int maxResultsPerSource = 30; PassthroughQuery q = new PassthroughQuery(); q.QueryString = queryString; q.AddRepository(DefaultRepository); QueryExecution queryExec = new QueryExecution(startingIndex, maxResults, maxResultsPerSource); queryExec.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryResult = searchService.Execute(q, queryExec, null); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Console.WriteLine(repStatusInfo.ErrorTrace); throw new Exception("Query failed to return result."); } Console.WriteLine("Query returned result successfully."); DataPackage dp = queryResult.DataPackage; Console.WriteLine("DataPackage contains " + dp.DataObjects.Count + " objects."); foreach (DataObject dObj in dp.DataObjects) { //Console.WriteLine(dObj.Identity.GetValueAsString()); // PropertySet docProperties = dObj.Properties; String objectId = dObj.Identity.GetValueAsString(); String docName = docProperties.Get("object_name").GetValueAsString(); Console.WriteLine("Document " + objectId + " name is " + docName); // result = result + Environment.NewLine + "Document " + objectId + " name is " + docName; //lstCabinets.Add(new CabinetModel() { ObjectId = objectId, ObjectName = docName }); // } return(queryResult); }
/// <summary> /// Esegue una DQL di tipo UPDATE o DDL (ALTER...) /// </summary> /// <param name="qrySrvc"></param> /// <param name="dql"></param> /// <returns></returns> public static QueryResult executePassThrough(IQueryService qrySrvc, string dql) { string repositoryName = DctmConfigurations.GetRepositoryName(); PassthroughQuery query = new PassthroughQuery(); query.QueryString = dql; query.AddRepository(repositoryName); QueryExecution queryEx = new QueryExecution(); queryEx.MaxResultCount = -1; // Nessun limite di risultati restituiti queryEx.MaxResultPerSource = -1; queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; OperationOptions operationOptions = null; return(qrySrvc.Execute(query, queryEx, operationOptions)); }
public DataPackage GetLifecycles(String repository) { ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = null; queryService = serviceFactory .GetRemoteService <IQueryService>(lifecycleService.GetServiceContext()); PassthroughQuery query = new PassthroughQuery(); // this query does not necessarily contain everything you will need // but shows most of the lifecycle-related properties on dm_policy query.QueryString = "select r_object_id, " + "object_name, " + "acl_name, " + "included_type, " + "include_subtypes, " + "state_name, " + "state_description, " + "state_class, " + "r_resume_state, " + "r_current_state, " + "entry_criteria_id, " + "user_criteria_id, " + "action_object_id, " + "user_action_id, " + "exception_state, " + "allow_attach, " + "allow_schedule, " + "return_to_base, " + "allow_demote, " + "alias_set_ids, " + "return_condition " + "from dm_policy"; query.AddRepository(repository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; queryEx.MaxResultCount = 50; OperationOptions operationOptions = null; Console.WriteLine("Executing query " + query.QueryString); QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); return(queryResult.DataPackage); }
/// <summary> /// Creates a new flattened metric from the query execution data /// </summary> /// <param name="queryExecution"></param> /// <returns></returns> public static AthenaQueryMetric Build(QueryExecution queryExecution) { return(new AthenaQueryMetric( queryExecution.QueryExecutionId, queryExecution.StatementType, queryExecution.Statistics.DataScannedInBytes, queryExecution.Statistics.EngineExecutionTimeInMillis, queryExecution.Status.CompletionDateTime.ToUniversalTime(), queryExecution.Status.SubmissionDateTime.ToUniversalTime(), queryExecution.Status.State, queryExecution.QueryExecutionContext.Database, Convert.ToBase64String(Encoding.UTF8.GetBytes(queryExecution.Query)), queryExecution.ResultConfiguration.OutputLocation, queryExecution.ResultConfiguration.EncryptionConfiguration == null ? String.Empty : queryExecution.ResultConfiguration.EncryptionConfiguration.EncryptionOption.Value, queryExecution.ResultConfiguration.EncryptionConfiguration == null ? String.Empty : queryExecution.ResultConfiguration.EncryptionConfiguration.KmsKey )); }
protected IRacoonResponse TryExecuteQueryMultiVariable(byte[] token, string sproc, IEnumerable <IConvertToMiddlewareParam> inputParams) { IRacoonResponse executeResponse = QueryExecution.ExecuteQueryAllTypes(token, sproc, inputParams, ParameterTypeEnum.AsSource | ParameterTypeEnum.Multivalue); if (!executeResponse.AuthorisationOK) { return(executeResponse); } MultiVariableResponse queryRes = executeResponse as MultiVariableResponse; if (queryRes == null) { executeResponse.Status = false; executeResponse.Error = new InvalidCastException("Unexpected return type from query"); } return(executeResponse); }
public SimpleRacoonResponse InsertSingleTriple(byte[] token, string subj, string pred, string obj, string graph) { Exception error = null; SimpleRacoonResponse res = new SimpleRacoonResponse(); Session currentSession; if (SessionStore.TryGetValidSession(token, out currentSession)) { error = InsertSingleTripleExec(subj, pred, obj, graph, currentSession); QueryExecution.SuccessResponse(res, error); } else { QueryExecution.SecurityFailureResponse(res); } return(res); }
/// <summary> /// Poll API to determine when the query completed /// </summary> public async Task PoolQueryExecutionAsync(string queryExecutionId, int delayMs = 5000) { QueryExecution queryExecution = null; var executingStates = new string[] { QueryExecutionState.RUNNING, QueryExecutionState.QUEUED }; var unsuccessStates = new string[] { QueryExecutionState.CANCELLED, QueryExecutionState.FAILED }; do { try { _logger.LogDebug($"PoolQueryExecutionAsync for 'queryExecutionId': '{queryExecutionId}'."); var getQueryExecutionRequest = new GetQueryExecutionRequest() { QueryExecutionId = queryExecutionId }; var client = _amazonAthenaClientFactory.Create(); var getQueryExecutionAsyncResponse = await client.GetQueryExecutionAsync(getQueryExecutionRequest); getQueryExecutionAsyncResponse.EnsureSuccessStatusCode(); queryExecution = getQueryExecutionAsyncResponse.QueryExecution; _logger.LogDebug($"PoolQueryExecutionAsync state '{queryExecution.Status.State}', StateChangeReason: '{queryExecution.Status.StateChangeReason}' for 'queryExecutionId': '{queryExecutionId}'."); if (unsuccessStates.Any(state => queryExecution.Status.State.Equals(state))) { throw new Exception($"QueryExecution for 'queryExecutionId': '{queryExecutionId}' failed.", new Exception($"State '{queryExecution.Status.State}', StateChangeReason: '{queryExecution.Status.StateChangeReason}'.")); } await Task.Delay(delayMs); } catch (InvalidRequestException e) { _logger.LogError(e, $"Exception while executing PoolQueryExecutionAsync for 'queryExecutionId': '{queryExecutionId}'."); } }while (executingStates.Any(state => queryExecution.Status.State.Equals(state))); _logger.LogDebug($"Data Scanned for '{queryExecutionId}': '{queryExecution.Statistics.DataScannedInBytes}' Bytes."); }
public AclPackage GetOwnerPrivateAcls(String ownerName, String repository) { // instantiate a Query service proxy ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = null; queryService = serviceFactory.GetRemoteService <IQueryService>(accessControlService.GetServiceContext()); // build and run the query PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select owner_name, object_name from dm_acl " + "where r_is_internal='0' and acl_class='0' and owner_name='" + ownerName + "'"; query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; queryEx.MaxResultCount = -1; // no limit OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); DataPackage resultDp = queryResult.DataPackage; List <DataObject> dataObjects = resultDp.DataObjects; Console.WriteLine("Total objects returned is: " + dataObjects.Count); //convert the results into a List<AclIdentity> List <AclIdentity> identityList = new List <AclIdentity>(); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; AclIdentity aclIdentity = new AclIdentity(); aclIdentity.Domain = docProperties.Get("owner_name").GetValueAsString(); aclIdentity.Name = docProperties.Get("object_name").GetValueAsString(); aclIdentity.RepositoryName = repository; identityList.Add(aclIdentity); } // get and return the AclPackage return(accessControlService.Get(identityList)); }
public String GetUserNameFromRepository() { ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = serviceFactory .GetRemoteService <IQueryService>(serviceDemo.DemoServiceContext); PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select user_name from dm_user where user_login_name = '" + serviceDemo.UserName + "'"; query.AddRepository(serviceDemo.DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryEx.MaxResultCount = -1; // use default limit configured in dfs.properties OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); PropertySet objectProperties = queryResult.DataPackage.DataObjects[0].Properties; return(objectProperties.Get("user_name").GetValueAsString()); }
/* * Sequentially processes a cached query result * Terminates when end of query result is reached */ public void CachedPassthroughQuery() { PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select r_object_id, " + "object_name from dm_cabinet"; Console.WriteLine("Query string is " + query.QueryString); query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); OperationOptions operationOptions = null; queryEx.CacheStrategyType = CacheStrategyType.BASIC_FILE_CACHE_STRATEGY; Console.WriteLine("CacheStrategyType == " + queryEx.CacheStrategyType); queryEx.MaxResultCount = 10; Console.WriteLine("MaxResultCount = " + queryEx.MaxResultCount); while (true) { QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); DataPackage resultDp = queryResult.DataPackage; List <DataObject> dataObjects = resultDp.DataObjects; if (dataObjects.Count == 0) { break; } Console.WriteLine("Total objects returned is: " + dataObjects.Count); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; String objectId = dObj.Identity.GetValueAsString(); String cabinetName = docProperties.Get("object_name").GetValueAsString(); Console.WriteLine("Cabinet " + objectId + " name is " + cabinetName); } queryEx.StartingIndex += 10; } }
/// <summary> /// /// </summary> /// <param name="query"></param> /// <returns></returns> protected virtual CheckOutStatus[] GetCheckOutStatusDocuments(PassthroughQuery query) { List <CheckOutStatus> list = new List <CheckOutStatus>(); try { QueryExecution queryExecution = new QueryExecution(); queryExecution.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; // Reperimento istanza queryservice IQueryService service = this.GetServiceInstance <IQueryService>(true); QueryResult result = service.Execute(query, queryExecution, null); if (result.DataPackage != null) { foreach (DataObject dataObject in result.DataPackage.DataObjects) { // Creazione oggetto "CheckOutStatus" list.Add(this.CreateCheckOutStatus(dataObject)); } } } catch (Exception ex) { list = null; logger.Debug("Errore in Documentum. GetCheckOutStatusDocuments: " + ex.ToString()); } if (list != null) { return(list.ToArray()); } else { return(null); } }
public QueryResult SimplePassthroughQuery() { QueryResult queryResult; string queryString = "select distinct r_object_id from dm_document order by r_object_id "; int startingIndex = 0; int maxResults = 60; int maxResultsPerSource = 20; PassthroughQuery q = new PassthroughQuery(); q.QueryString = queryString; q.AddRepository(DefaultRepository); QueryExecution queryExec = new QueryExecution(startingIndex, maxResults, maxResultsPerSource); queryExec.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryResult = searchService.Execute(q, queryExec, null); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Console.WriteLine(repStatusInfo.ErrorTrace); throw new Exception("Query failed to return result."); } Console.WriteLine("Query returned result successfully."); DataPackage dp = queryResult.DataPackage; Console.WriteLine("DataPackage contains " + dp.DataObjects.Count + " objects."); foreach (DataObject dataObject in dp.DataObjects) { Console.WriteLine(dataObject.Identity.GetValueAsString()); } return(queryResult); }
public TaskOntologyResponse GetTaskOntologies(byte[] token) { IRacoonResponse executeResponse = QueryExecution.ExecuteQueryAllTypes(token, SprocNames.GetTaskOntologies, Enumerable.Empty <IConvertToMiddlewareParam>(), ParameterTypeEnum.String & ParameterTypeEnum.Multivalue); TaskOntologyResponse response = new TaskOntologyResponse(executeResponse); if (!response.AuthorisationOK) { return(response); } MultiVariableResponse queryRes = executeResponse as MultiVariableResponse; if (queryRes == null) { response.Status = false; response.Error = new InvalidCastException("Unexpected return type from query"); return(response); } else { List <TaskOntologyDataContract> returnableTaskOntologyList = new List <TaskOntologyDataContract>(); foreach (MultiParameterResult param in queryRes.OutputParameters) { if (param.Direction == ParameterDirection.Out) { MiddlewareParameter <List <MiddlewareParameter> > convertedParameter = (MiddlewareParameter <List <MiddlewareParameter> >)param.ToMiddlewareParam(); TaskOntology availableTaskOntology = MappedBussinessObjectFactory.CreateFromParamers <TaskOntology>(convertedParameter.ParamValue); TaskOntologyDataContract returnableTaskOntology = new TaskOntologyDataContract(availableTaskOntology); returnableTaskOntologyList.Add(returnableTaskOntology); } } if (returnableTaskOntologyList.Count > 0) { response.TaskOntologies = returnableTaskOntologyList; } } return(response); }
public void BasicPassthroughQuery() { PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select r_object_id, " + "object_name from dm_cabinet"; query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); Console.WriteLine("QueryId == " + query.QueryString); Console.WriteLine("CacheStrategyType == " + queryEx.CacheStrategyType); DataPackage resultDp = queryResult.DataPackage; List<DataObject> dataObjects = resultDp.DataObjects; Console.WriteLine("Total objects returned is: " + dataObjects.Count); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; String objectId = dObj.Identity.GetValueAsString(); String docName = docProperties.Get("object_name").GetValueAsString(); Console.WriteLine("Document " + objectId + " name is " + docName); } }
/* * Sequentially processes a cached query result * Terminates when end of query result is reached */ public void CachedPassthroughQuery() { PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select r_object_id, " + "object_name from dm_cabinet"; Console.WriteLine("Query string is " + query.QueryString); query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); OperationOptions operationOptions = null; queryEx.CacheStrategyType = CacheStrategyType.BASIC_FILE_CACHE_STRATEGY; Console.WriteLine("CacheStrategyType == " + queryEx.CacheStrategyType); queryEx.MaxResultCount = 10; Console.WriteLine("MaxResultCount = " + queryEx.MaxResultCount); while (true) { QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); DataPackage resultDp = queryResult.DataPackage; List<DataObject> dataObjects = resultDp.DataObjects; if (dataObjects.Count == 0) { break; } Console.WriteLine("Total objects returned is: " + dataObjects.Count); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; String objectId = dObj.Identity.GetValueAsString(); String cabinetName = docProperties.Get("object_name").GetValueAsString(); Console.WriteLine("Cabinet " + objectId + " name is " + cabinetName); } queryEx.StartingIndex += 10; } }
///// <summary> ///// Reperimento dipendenze per l'oggetto richiesto ///// </summary> ///// <param name="fieldValue"></param> ///// <param name="tableName"></param> ///// <param name="fieldName"></param> ///// <param name="repeating"></param> ///// <returns></returns> //protected ObjectIdentity[] GetObjectDependencies(string fieldValue, string tableName, string fieldName, bool repeating) //{ // List<ObjectIdentity> list = new List<ObjectIdentity>(); // PassthroughQuery query = new PassthroughQuery(); // string dql = null; // if (repeating) // dql = "SELECT r_object_id FROM {0} WHERE ANY upper({1}) = upper('{2}')"; // else // dql = "SELECT r_object_id FROM {0} WHERE upper({1}) = upper('{2}')"; // query.QueryString = string.Format(dql, tableName, fieldName, // fieldValue.Replace("'", "''")); // query.AddRepository(DctmConfigurations.GetRepositoryName()); // QueryExecution queryEx = new QueryExecution(); // queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; // OperationOptions operationOptions = null; // QueryResult queryResult = this.GetQueryServiceInstance().Execute(query, queryEx, operationOptions); // if (queryResult.DataObjects.Count > 0) // { // ObjectId objId = (ObjectId)queryResult.DataObjects[0].Identity.Value; // list.Add(DfsHelper.createObjectIdentityObjId(objId)); // } // return list.ToArray(); //} protected void checkReference(string fieldValue, string tableName, string fieldName, bool repeating) { IQueryService qrySrvc = null; string repositoryName = DctmConfigurations.GetRepositoryName(); qrySrvc = this.GetQueryServiceInstance(); PassthroughQuery query = new PassthroughQuery(); string dql = null; if (repeating) { dql = "SELECT r_object_id FROM {0} WHERE ANY lower({1}) = lower('{2}')"; } else { dql = "SELECT r_object_id FROM {0} WHERE lower({1}) = lower('{2}')"; } query.QueryString = string.Format(dql, tableName, fieldName, fieldValue.Replace("'", "''")); query.AddRepository(repositoryName); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; OperationOptions operationOptions = null; QueryResult queryResult = qrySrvc.Execute(query, queryEx, operationOptions); // il risultato dovrebbe essere vuoto if (queryResult.DataObjects.Count > 0) { ObjectId objId = (ObjectId)queryResult.DataObjects[0].Identity.Value; throw new Exception(string.Format("Non รจ possibile cancellare {0}, in quanto referenziato l'oggetto con id={1}", fieldValue, objId.Id)); } }
private static QueryExecution GetQueryExecution(Dictionary <string, string> queryFilterValues, int?page, int?itemsPerPage) { var filterValues = new List <FilterValue>(); filterValues.AddRange(queryFilterValues.Select(queryFilterValue => new FilterValue { FieldName = queryFilterValue.Key, FieldValue = queryFilterValue.Value })); var queryExecution = new QueryExecution { FilterValues = filterValues.Where(x => !string.IsNullOrEmpty(x.FieldValue)).ToArray(), SortValues = new SortValue[0] }; if (page.HasValue && itemsPerPage.HasValue) { queryExecution.PageNumber = page; queryExecution.PageSize = itemsPerPage; } return(queryExecution); }
public void SimpleStructuredQuery(String docName) { String repoName = DefaultRepository; PropertyProfile propertyProfile = new PropertyProfile(); propertyProfile.FilterMode = PropertyFilterMode.IMPLIED; OperationOptions operationOptions = new OperationOptions(); operationOptions.Profiles.Add(propertyProfile); // Create query StructuredQuery q = new StructuredQuery(); q.AddRepository(repoName); q.ObjectType = "dm_document"; q.IsIncludeHidden = true; q.IsDatabaseSearch = true; ExpressionSet expressionSet = new ExpressionSet(); expressionSet.AddExpression(new PropertyExpression("object_name", Condition.CONTAINS, docName)); q.RootExpressionSet = expressionSet; // Execute Query int startingIndex = 0; int maxResults = 60; int maxResultsPerSource = 20; QueryExecution queryExec = new QueryExecution(startingIndex, maxResults, maxResultsPerSource); QueryResult queryResult = searchService.Execute(q, queryExec, operationOptions); QueryStatus queryStatus = queryResult.QueryStatus; RepositoryStatusInfo repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Console.WriteLine(repStatusInfo.ErrorTrace); throw new Exception("Query failed to return result."); } Console.WriteLine("Query returned result successfully."); // print results Console.WriteLine("DataPackage contains " + queryResult.DataObjects.Count + " objects."); foreach (DataObject dataObject in queryResult.DataObjects) { Console.WriteLine(dataObject.Identity.GetValueAsString()); } }
public IList<DataObject> FindDataObjects(string objectType, List<PropertyExpression> searchCriteria, bool getContent) { Log.Verbose("DataObjectRepository FindDataObjects criteria {@searchCriteria}", searchCriteria); var propertyProfile = new PropertyProfile {FilterMode = PropertyFilterMode.IMPLIED}; var operationOptions = new OperationOptions(); operationOptions.Profiles.Add(propertyProfile); // Create query var query = new StructuredQuery(); query.AddRepository(dfsConfiguration.Repository); query.ObjectType = objectType; query.IsIncludeHidden = true; query.IsDatabaseSearch = true; if (searchCriteria != null && searchCriteria.Count > 0) { query.RootExpressionSet = new ExpressionSet(); foreach (var expression in searchCriteria) { query.RootExpressionSet.AddExpression(expression); } } // Execute Query const int StartingIndex = 0; int maxResults = dfsConfiguration.MaxQueryResults; var queryExec = new QueryExecution(StartingIndex, maxResults, maxResults); var queryResult = dfsContext.SearchService.Execute(query, queryExec, operationOptions); var queryStatus = queryResult.QueryStatus; var repStatusInfo = queryStatus.RepositoryStatusInfos[0]; if (repStatusInfo.Status == Status.FAILURE) { Log.Debug("FindDataObjects failed {@searchCriteria}", searchCriteria); return null; } Log.Debug("FindDataObjects found {0} objects", queryResult.DataObjects.Count); //TODO see if there is a better way to get the contents from a search return queryResult.DataObjects .Select(dataObject => getContent ? GetDataObjectWithContentsObjectId(dataObject.Identity.GetValueAsString()) : GetDataObjectByObjectId(dataObject.Identity.GetValueAsString())) .ToList(); }
public AclPackage GetOwnerPrivateAcls(String ownerName, String repository) { // instantiate a Query service proxy ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = null; queryService = serviceFactory.GetRemoteService<IQueryService>(accessControlService.GetServiceContext()); // build and run the query PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select owner_name, object_name from dm_acl " + "where r_is_internal='0' and acl_class='0' and owner_name='" + ownerName + "'"; query.AddRepository(DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; queryEx.MaxResultCount = -1; // no limit OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); DataPackage resultDp = queryResult.DataPackage; List<DataObject> dataObjects = resultDp.DataObjects; Console.WriteLine("Total objects returned is: " + dataObjects.Count); //convert the results into a List<AclIdentity> List<AclIdentity> identityList = new List<AclIdentity>(); foreach (DataObject dObj in dataObjects) { PropertySet docProperties = dObj.Properties; AclIdentity aclIdentity = new AclIdentity(); aclIdentity.Domain = docProperties.Get("owner_name").GetValueAsString(); aclIdentity.Name = docProperties.Get("object_name").GetValueAsString(); aclIdentity.RepositoryName = repository; identityList.Add(aclIdentity); } // get and return the AclPackage return accessControlService.Get(identityList); }
public DataPackage GetLifecycles(String repository) { ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = null; queryService = serviceFactory .GetRemoteService<IQueryService>(lifecycleService.GetServiceContext()); PassthroughQuery query = new PassthroughQuery(); // this query does not necessarily contain everything you will need // but shows most of the lifecycle-related properties on dm_policy query.QueryString = "select r_object_id, " + "object_name, " + "acl_name, " + "included_type, " + "include_subtypes, " + "state_name, " + "state_description, " + "state_class, " + "r_resume_state, " + "r_current_state, " + "entry_criteria_id, " + "user_criteria_id, " + "action_object_id, " + "user_action_id, " + "exception_state, " + "allow_attach, " + "allow_schedule, " + "return_to_base, " + "allow_demote, " + "alias_set_ids, " + "return_condition " + "from dm_policy"; query.AddRepository(repository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.DEFAULT_CACHE_STRATEGY; queryEx.MaxResultCount = 50; OperationOptions operationOptions = null; Console.WriteLine("Executing query " + query.QueryString); QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); return queryResult.DataPackage; }
public String GetUserNameFromRepository() { ServiceFactory serviceFactory = ServiceFactory.Instance; IQueryService queryService = serviceFactory .GetRemoteService<IQueryService>(serviceDemo.DemoServiceContext); PassthroughQuery query = new PassthroughQuery(); query.QueryString = "select user_name from dm_user where user_login_name = '" + serviceDemo.UserName + "'"; query.AddRepository(serviceDemo.DefaultRepository); QueryExecution queryEx = new QueryExecution(); queryEx.CacheStrategyType = CacheStrategyType.NO_CACHE_STRATEGY; queryEx.MaxResultCount = -1; // use default limit configured in dfs.properties OperationOptions operationOptions = null; QueryResult queryResult = queryService.Execute(query, queryEx, operationOptions); PropertySet objectProperties = queryResult.DataPackage.DataObjects[0].Properties; return objectProperties.Get("user_name").GetValueAsString(); }