Class: Mio::Model::ImportAction

Inherits:
Mio::Model show all
Defined in:
lib/mio/model/import_action.rb

Instance Attribute Summary

Attributes inherited from Mio::Model

#args, #client, #search

Instance Method Summary collapse

Methods inherited from Mio::Model

#configure, #create, field, #go, #initialize, mappings, nested, #set_enable, set_resource, #set_start, #validate

Constructor Details

This class inherits a constructor from Mio::Model

Instance Method Details

#config_hashObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/mio/model/import_action.rb', line 35

def config_hash
  h = {
    "source-file": {
      "source": {
        "vfs-source-file-path": {
          "protocol": {
            "value": "S3",
            "isExpression": false
          },
          "path": {
            "value": @args.s3PathVariable,
            "isExpression": false
          },
          "key": {
            "value": @args['key'],
            "isExpression": false
          },
          "secret": {
            "value":  @args.secret,
            "isExpression": false
          },
          "bucket": {
            "value": @args.bucket,
            "isExpression": false

          }
        }
      },
      "keep-source-filename": false
    },
    "asset-details": {
      "title": {
        "value": @args.assetTitleVariable,
        "isExpression": false

      },
      "asset-origin": {
        "value": @args.creationContext,
        "isExpression": false
      }
    }
  }

  unless @args.variant.to_s == ''
    h[:"variant-and-metadata-definition"] = { "variant": { "value": @args.variant, "isExpression": false } }

    unless @args.metadataDefinition.to_s == ''
       = @search.find_metadataDefinitions_by_name(@args.metadataDefinition).first
      if .nil?
        raise Mio::Model::NoSuchResource, 'No such metadata definition [' + @args.metadataDefinition + ']'
      end
      h[:"variant-and-metadata-definition"]["metadata"] = { "metadata-definition": { "id": ['id']},
                                                      "source-json-variable": {"value": @args.sourceJsonVariable,  "isExpression": false}
                                                     }
    end
  end

  unless @args.parentAssetId.to_s == ''
    h["asset-relationships"] = {
        "child": {
          "parent": {
              "parent-asset-id": {
                  "value": @args.parentAssetId,
                  "isExpression": false
              }
          },
          "reference-name": {
              "value": @args.parentRelationName,
              "isExpression": false
          }
        }
    }
  end

  unless @args.memberAssetId.to_s == ''
    h["asset-relationships"] = {
        "member": { "group": { "group-asset-id": { "value": @args.memberAssetId, "isExpression": false } },
                  "membership-name": {"value": @args.memberAssetRelationName, "isExpression": false} }
    }
  end

  h
end

#create_hashObject



25
26
27
28
29
30
31
32
33
# File 'lib/mio/model/import_action.rb', line 25

def create_hash
  plugin = 'tv.nativ.mio.enterprise.execution.action.file.impl.objectimport.vfs.AssetImportCommand'
  {name: @args.name,
   pluginClass: plugin,
   visibilityIds: @args.visibility,
   'type': 'import',
   'runRuleExpression': @args.runRuleExpression
  }
end