Queuing mechanism on create?

Queuing mechanism on create?

esmurfesmurf Posts: 29Questions: 4Answers: 0
edited December 2018 in Editor

Hi!

I was wondering if there's any queuing mechanism added to the Editor? I've read several post back from 2015/2016 that it would be added to the future and I'll be needing it for editor.create().

I'm reading text files into an array which have 1000+ rows and columns. I've experienced that it's not possible to loop through it like so:

function importFile (ged) {
        for (let j= 0; j< ged.length; j++) {
            editorVulnerability.create(false)
                .set('testtypeid', ged[j][0])
                .set('toolid', ged[j][1])
                .set('outputtool', ged[j][2])
                .set('scanid', ged[j][3])
                .set('fp', ged[j][4])
                .set('cvss_temp', ged[j][5])
                .set('cvss_env', ged[j][6])
                .set('cvss_base_new', ged[j][7])
                .set('vuln_not_in_report', ged[j][8])
                .set('ip', ged[j][9])
                .set('mac', ged[j][10])
                .set('netbiosname', ged[j][11])
                .set('os', ged[j][12])
                .set('start', ged[j][13])
                .set('stop', ged[j][14])
                .set('plugin_id', ged[j][15])
                .set('plugin_name', ged[j][16])
                .set('port', ged[j][17])
                .set('protocol', ged[j][18])
                .set('cve', ged[j][19])
                .set('cvss_base_score', ged[j][20])
                .set('service_name', ged[j][21])
                .set('description', ged[j][22])
                .set('solution', ged[j][23])
                .submit();
        } 

If there's any solution to wait for the data to be submitted and then continue with the loop I would love to hear it! Or any other suggestions.

Have a great day!

This question has an accepted answers - jump to answer

Answers

  • esmurfesmurf Posts: 29Questions: 4Answers: 0

    I found a solution, but I'm not too happy about it..

    function importFile (ged, j) {
            console.log(ged);
              editorVulnerability.create(false)
                    .set('testtypeid', ged[j][0])
                    .set('toolid', ged[j][1])
                    .set('outputtool', ged[j][2])
                    .set('scanid',ged[j][3])
                    .set('fp', ged[j][4])
                    .set('cvss_temp', ged[j][5])
                    .set('cvss_env', ged[j][6])
                    .set('cvss_base_new', ged[j][7])
                    .set('vuln_not_in_report', ged[j][8])
                    .set('ip', ged[j][9])
                    .set('mac', ged[j][10])
                    .set('netbiosname', ged[j][11])
                    .set('os', ged[j][12])
                    .set('start', ged[j][13])
                    .set('stop', ged[j][14])
                    .set('plugin_id', ged[j][15])
                    .set('plugin_name', ged[j][16])
                    .set('port', ged[j][17])
                    .set('protocol', ged[j][18])
                    .set('cve', ged[j][19])
                    .set('cvss_base_score', ged[j][20])
                    .set('service_name', ged[j][21])
                    .set('description', ged[j][22])
                    .set('solution', ged[j][23])
                    .submit(function () {
                        console.log(j);
                        j++;
                        setTimeout(function() {
                            importFile(ged, j);
                        }, 2000) ;
                        });
    

    Still if there's any form of queuing mechanism for the editor, I'll be glad to hear about it!

  • allanallan Posts: 61,669Questions: 1Answers: 10,096 Site admin
    Answer ✓

    Yup - there is a better way :). The create() method has an optional parameter that can be set to tell it how many rows to create. Then use the multi-row editing api (specifically field().multiSet() in this case) to set the values you need. Then a single submit() call is all that is needed.

    This assumes that whatever you are using on the server-side works for multi-row editing of course.

    Allan

This discussion has been closed.