Skip to content

Conversation

dmcassel
Copy link
Contributor

No description provided.

@dmcassel dmcassel requested a review from paxtonhare November 10, 2017 20:15
this.finalClient = hubConfig.newFinalClient();
this.jobClient = hubConfig.newJobDbClient();
this.jobManager = new JobManager(this.jobClient);
this.jobManager = new JobManager(this.jobClient, hubConfig.traceDbName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at the $config:JOB-DATABASE variable in xquery. You don't need to pass this arround.

import module namespace config = "http://marklogic.com/data-hub/config"
  at "/com.marklogic.hub/lib/config.xqy";

import java.util.TimeZone;

public class JobManager {
public class JobManager extends ResourceManager {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something tells me you didn't want to inherit this here.

$input as document-node()*
) as document-node()*
{
xdmp:log("delete-jobs: " || xdmp:quote($params)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please wrap this entry point in:

perf:log('/v1/resources/flow:post', function() {
  (: your stuff :)
})

$input as document-node()*
) as document-node()*
{
xdmp:log("delete-jobs: " || xdmp:quote($params)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, use debug:log instead of xdmp:log. better yet, leave 'em out.

service:delete-traces($job-ids)
},
<options xmlns="xdmp:eval">
<database>{xdmp:database(map:get($params, "tracingDB"))}</database>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this goes back to my first comment at the top of the page. use $config:JOB-DATABASE


declare option xdmp:mapping "false";

declare private function service:delete-jobs($job-ids as xs:string*) as map:map
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put these private methods in a com.marklogic.hub/job-lib.xqy to be consistent with the other stuff.

public static void setupSuite() throws IOException {
XMLUnit.setIgnoreWhitespace(true);
File projectDirFile = projectDir.toFile();
if (projectDirFile.isDirectory() && projectDirFile.exists()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a method in HubTestBase to delete the project dir for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh. This was a copy/paste. But I'll look for that method.

scaffolding.createFlow(ENTITY, "testharmonize", FlowType.HARMONIZE,
CodeFormat.XQUERY, DataFormat.XML);

DataHub dh = new DataHub(getHubConfig());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a getDataHub() convenience method for you in HubTestBase

</mdl-button>
</td>
<td class="job-delete-checkbox">
<input type="checkbox" id="list-checkbox-{{job.jobId}}" class="mdl-checkbox__input"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check out mdl-checkbox: http://mseemann.io/angular2-mdl/toggle

It's prettier.

@dmcassel
Copy link
Contributor Author

Add a confirmation before deleting the jobs. See the skull button on the Dashboard for an example.

let $results := map:map()
let $_ :=
for $id in $job-ids
let $uri := cts:uris((), (), cts:json-property-value-query("jobId", $id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this be done like so?

for $uri in cts:uris((), (), cts:json-property-value-query("jobId", $job-ids))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also using the $id in reporting back in the $results map, so I do need $id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. cool.

{
for $id in $job-ids
let $traces := /trace[jobId = $id]/traceId
for $trace in $traces
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silly nitpick.... remove the $traces var

for $id in $job-ids
let $traces := /trace[jobId = $id]/traceId
for $trace in $traces
let $_ := xdmp:document-delete(fn:base-uri($trace))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's also xdmp:node-uri. I forget... but I think base-uri can have unintended results in some situations. unlikely here.

assertEquals(0, actual.totalCount);
assertEquals(1, actual.errorCount);

}
Copy link
Contributor

@paxtonhare paxtonhare Nov 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for grins can you do 2 more tests? one with "" as the id param and one with null as the param.

import com.marklogic.hub.flow.Flow;
import com.marklogic.hub.flow.FlowType;
import com.marklogic.quickstart.EnvironmentAware;
import com.marklogic.quickstart.model.EnvironmentConfig;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

loadingJobs: boolean = false;
searchResponse: SearchResponse;
jobs: Array<Job>;
jobsToDelete: any = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind typing this to string or whatever it should be? same for the funcs below.


import com.marklogic.client.DatabaseClient;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.io.StringHandle;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary?

MarkLogic 8.0-7 has a bug regarding transaction mode, which is fixed in
8.0-7.1. Made some changes to get the extension to work right in 8.0-7.
@dmcassel
Copy link
Contributor Author

The Travis build is broken, but only with that one test we discussed. All others are passing (after building in special cases for 8.0-7 and 9.0-1.1).

Copy link
Contributor

@paxtonhare paxtonhare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only 1 comment

let $options :=
<options xmlns="xdmp:eval">
{
if (xdmp:version() = "9.0-1.1") then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 9.0-1.1 the only outlier here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

among the supported versions (8.0-7+ and 9.0-1.1+), yes

let $results := map:map()
let $_ :=
for $id in $job-ids
let $uri := cts:uris((), (), cts:json-property-value-query("jobId", $id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. cool.

@dmcassel dmcassel merged commit 0407b1a into develop Nov 28, 2017
@dmcassel dmcassel deleted the feature/delete-old-jobs branch November 28, 2017 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants