func (op deviceServiceLoadByAddressable) Execute() ([]contract.DeviceService, error) {
	var addr contract.Addressable
	var err error

	// Check if the Addressable exists
	// determine whether we're doing a lookup by ID or name
	if op.id != "" {
		addr, err = op.db.GetAddressableById(op.id)
		if err == db.ErrNotFound {
			err = errors.NewErrItemNotFound(op.id)
		}
	} else {
		addr, err = op.db.GetAddressableByName(op.name)
		if err == db.ErrNotFound {
			err = errors.NewErrItemNotFound(op.name)
		}
	}

	if err != nil {
		return nil, err
	}

	if ds, err := op.db.GetDeviceServicesByAddressableId(addr.Id); err != nil {
		return nil, err
	} else {
		return ds, nil
	}
}
// Execute performs an operation that retrieves all DeviceService associated with a given Addressable.
Execute performs an operation that retrieves all DeviceService associated with a given Addressable.
// Execute performs an operation that retrieves all DeviceService associated with a given Addressable .
func (op deviceServiceLoadByAddressable) Execute() ([]contract.DeviceService, error) {
	var addr contract.Addressable
	var err error
	if op.id != "" {
		addr, err = op.db.GetAddressableById(op.id)
		if err == db.ErrNotFound {
			err = errors.NewErrItemNotFound(op.id)
		}
	} else {
		addr, err = op.db.GetAddressableByName(op.name)
		if err == db.ErrNotFound {
			err = errors.NewErrItemNotFound(op.name)
		}
	}
	if err != nil {
		return nil, err
	}
	if ds, err := op.db.GetDeviceServicesByAddressableId(addr.Id); err != nil {
		return nil, err
	} else {
		return ds, nil
	}
}
func ( op deviceServiceLoadByAddressable ) Execute ( ) ( [ ] contract . DeviceService , error ) { var addr contract . Addressable var err error if op . id != " " { addr , err = op . db . GetAddressableById ( op . id ) if err == db . ErrNotFound { err = errors . NewErrItemNotFound ( op . id ) } } else { addr , err = op . db . GetAddressableByName ( op . name ) if err == db . ErrNotFound { err = errors . NewErrItemNotFound ( op . name ) } } if err != nil { return nil , err } if ds , err := op . db . GetDeviceServicesByAddressableId ( addr . Id ) ; err != nil { return nil , err } else { return ds , nil } }
Execute performs an operation that retrieves all DeviceService associated with a given Addressable.
Execute performs an operation that retrieves all DeviceService associated with a given Addressable .
// Check if the Addressable exists // determine whether we're doing a lookup by ID or name