lib/rest/change.rb
  Used to add restriction or other properties to the Property of a Class.
  See http://orientdb.com/docs/2.1/SQL-Alter-Property.html
Used to add restriction or other properties to the Property of a Class.
Used to add restriction or other properties to the Property of a Class .
def alter_property o_class, property:, attribute: "DEFAULT", alteration:  
    logger.progname = 'RestChange#AlterProperty'
    begin
      attribute.to_s! unless attribute.is_a? String
      attribute.capitalize_first_letter
      case attribute
      when "LINKEDCLASS", "LINKEDTYPE", "NAME", "REGEX", "TYPE", "REGEX", "COLLATE", "CUSTOM"
        unless alteration.is_a? String
          logger.error{"#{alteration} should be a String."}
          return 0
        end
      when "MIN", "MAX"
        unless alteration.is_a? Integer
          logger.error{"#{alteration} should be an Integer."}
          return 0
        end
      when "MANDATORY", "NOTNULL", "READONLY"
        unless alteration.is_a? TrueClass or alteration.is_a? FalseClass
          logger.error{"#{alteration} should be an Integer."}
          return 0
        end
      when "DEFAULT"
      else
        logger.error{"Wrong attribute."}
        return 0
      end
      name_class = classname(o_class)
      execute name_class, transaction: false do 
        [{ type: "cmd",
          language: 'sql',
          command: "ALTER PROPERTY #{name_class}.#{property} #{attribute} #{alteration}"}]
      end
    rescue Exception => e
      logger.error{e.message}
    end
  end
def alter_property o_class , property : , attribute : "DEFAULT" , alteration : logger . progname = 'RestChange#AlterProperty' begin attribute . to_s! unless attribute . is_a? String attribute . capitalize_first_letter case attribute when "LINKEDCLASS" , "LINKEDTYPE" , "NAME" , "REGEX" , "TYPE" , "REGEX" , "COLLATE" , "CUSTOM" unless alteration . is_a? String logger . error { "#{alteration} should be a String." } return 0 end when "MIN" , "MAX" unless alteration . is_a? Integer logger . error { "#{alteration} should be an Integer." } return 0 end when "MANDATORY" , "NOTNULL" , "READONLY" unless alteration . is_a? TrueClass or alteration . is_a? FalseClass logger . error { "#{alteration} should be an Integer." } return 0 end when "DEFAULT" else logger . error { "Wrong attribute." } return 0 end name_class = classname ( o_class ) execute name_class , transaction : false do [ { type : "cmd" , language : 'sql' , command : "ALTER PROPERTY #{name_class}.#{property} #{attribute} #{alteration}" } ] end rescue Exception => e logger . error { e . message } end end
Used to add restriction or other properties to the Property of a Class.
Used to add restriction or other properties to the Property of a Class .
# :nodoc: because untested # To execute commands
o_class
<not_specific>
property
<not_specific>
attribute
<not_specific>
alteration
<not_specific>