Search Results

Search found 16127 results on 646 pages for 'physical model'.

Page 8/646 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • OO Design / Patterns - Fat Model Vs Transaction Script?

    - by ben
    Ok, 'Fat' Model and Transaction Script both solve design problems associated with where to keep business logic. I've done some research and popular thought says having all business logic encapsulated within the model is the way to go (mainly since Transaction Script can become really complex and often results in code duplication). However, how does this work if I want to use the TDG of a second Model in my business logic? Surely Transaction Script presents a neater, less coupled solution than using one Model inside the business logic of another? A practical example... I have two classes: User & Alert. When pushing User instances to the database (eg, creating new user accounts), there is a business rule that requires inserting some default Alerts records too (eg, a default 'welcome to the system' message etc). I see two options here: 1) Add this rule as a User method, and in the process create a dependency between User and Alert (or, at least, Alert's Table Data Gateway). 2) Use a Transaction Script, which avoids the dependency between models. (Also, means the business logic is kept in a 'neutral' class & easily accessible by Alert. That probably isn't too important here, though). User takes responsibility for it's own validation etc, however, but because we're talking about a business rule involving two Models, Transaction Script seems like a better choice to me. Anyone spot flaws with this approach?

    Read the article

  • ASP.NET MVC - Binding a Child Entity to the Model

    - by Nathan Taylor
    This one seems painfully obvious to me, but for some reason I can't get it working the way I want it to. Perhaps it isn't possible the way I am doing it, but that seems unlikely. This question may be somewhat related: http://stackoverflow.com/questions/1274855/asp-net-mvc-model-binding-related-entities-on-same-page. I have an EditorTemplate to edit an entity with multiple related entity references. When the editor is rendered the user is given a drop down list to select related entities from, with the drop down list returning an ID as its value. <%=Html.DropDownListFor(m => m.Entity.ID)%> When the request is sent the form value is named as expected: "Entity.ID", however my strongly typed Model defined as an action parameter doesn't have Entity.ID populated with the value passed in the request. public ActionResult AddEntity(EntityWithChildEntities entityWithChildEntities) { } I tried fiddling around with the Bind() attribute and specified Bind(Include = "Entity.ID") on the entityWithChildEntities, but that doesn't seem to work. I also tried Bind(Include = "Entity"), but that resulted in the ModelBinder attempting to bind a full "Entity" definition (not surprisingly). Is there any way to get the default model binder to fill the child entity ID or will I need to add action parameters for each child entity's ID and then manually copy the values into the model definition?

    Read the article

  • Pagination in a Rich Domain Model

    - by user246790
    I use rich domain model in my app. The basic ideas were taken there. For example I have User and Comment entities. They are defined as following: <?php class Model_User extends Model_Abstract { public function getComments() { /** * @var Model_Mapper_Db_Comment */ $mapper = $this->getMapper(); $commentsBlob = $mapper->getUserComments($this->getId()); return new Model_Collection_Comments($commentsBlob); } } class Model_Mapper_Db_Comment extends Model_Mapper_Db_Abstract { const TABLE_NAME = 'comments'; protected $_mapperTableName = self::TABLE_NAME; public function getUserComments($user_id) { $commentsBlob = $this->_getTable()->fetchAllByUserId((int)$user_id); return $commentsBlob->toArray(); } } class Model_Comment extends Model_Abstract { } ?> Mapper's getUserComments function simply returns something like: return $this->getTable->fetchAllByUserId($user_id) which is array. fetchAllByUserId accepts $count and $offset params, but I don't know to pass them from my Controller to this function through model without rewriting all the model code. So the question is how can I organize pagination through model data (getComments). Is there a "beatiful" method to get comments from 5 to 10, not all, as getComments returns by default.

    Read the article

  • Formating a table date field from the Model in Codeigniter

    - by Landitus
    Hi, I', trying to re-format a date from a table in Codeigniter. The Controller is for a blog. I was succesfull when the date conversion happens in the View. I was hoping to convert the date in the Model to have things in order. Here's the date conversion as it happens in the View. This is inside the posts loop: <?php foreach($records as $row) : ?> <?php $fdate = "%d <abbr>%M</abbr> %Y"; $dateConv = mdate($fdate, mysql_to_unix($row->date)); ?> <div class="article section"> <span class="date"><?php echo $dateConv ;?></span> ... Keeps going ... This is the Model: class Novedades_model extends Model { function getAll() { $this->db->order_by('date','desc'); $query = $this->db->get('novedades'); if($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } } return $data; } } How can I convert the date in the Model? Can I access the date key and refactor it?

    Read the article

  • In Rails, a Sweeper isn't getting called in a Model-only setup

    - by charliepark
    I'm working on a Rails app, where I'm using page caching to store static html output. The caching works fine. I'm having trouble expiring the caches, though. I believe my problem is, in part, because I'm not expiring the cache from my controller. All of the actions necessary for this are being handled within the model. This seems like it should be doable, but all of the references to Model-based cache expiration that I'm finding seem to be out of date, or are otherwise not working. In my environment.rb file, I'm calling config.load_paths += %W( #{RAILS_ROOT}/app/sweepers ) And I have, in the /sweepers folder, a LinkSweeper file: class LinkSweeper < ActionController::Caching::Sweeper observe Link def after_update(link) clear_links_cache(link) end def clear_links_cache(link) # expire_page :controller => 'links', :action => 'show', :md5 => link.md5 expire_page '/l/'+ link.md5 + '.html' end end So ... why isn't it deleting the cached page when I update the model? (Process: using script/console, I'm selecting items from the database and saving them, but their corresponding pages aren't deleting from the cache), and I'm also calling the specific method in the Link model that would normally invoke the sweeper. Neither works. If it matters, the cached file is an md5 hash off a key value in the Links table. The cached page is getting stored as something like /l/45ed4aade64d427...99919cba2bd90f.html. Essentially, it seems as though the Sweeper isn't actually observing the Link. I also read (here) that it might be possible to simply add the sweeper to config.active_record.observers in environment.rb, but that didn't seem to do it (and I wasn't sure if the load_path of app/sweepers in environment.rb obviated that).

    Read the article

  • Calculate an AABB for bone animated model

    - by Byte56
    I have a model that has its initial bounding box calculated by finding the maximum and minimum on the x, y and z axes. Producing a correct result like so: The vertices are then stored in a VBO and only altered with matrices for rotation and bone animation. Currently the bounds are not updated when the model is altered. So the animated and rotated model has bounds like so: (Maybe it's hard to tell, but the bounds are the same as before, and don't accurately represent the rotated/animated model) So my question is, how can I calculate the bounding box using the armature matrices and rotation/translation matrices for each model? Keep in mind the modified vertex data is not available because those calculations are performed on the GPU in the shader. The end result I want is to have an accurate AABB the represents the animated model for picking/basic collision checks.

    Read the article

  • Please suggest me the ( Interaction model of view model) MVVM design in the simple scenario discusse

    - by Jack
    Data Layer I have an Order class as an entity. This Order entity is my model object. Order can be different types, let it be A B C D Also Order class may have common properties like Name, Time of creation, etc. Also based on the order type there are different fields that are not common. View Layer The view contains the following Main Menu ListView The Main Menu contains the drop down menu button which is used to create the order based on the type selected from the drop down. The drop down contains the Order types ( A ,B , C and D). There are different user control based on the order type. Like for example if user chooses to create an order of type A then different view with different inputs field is popped up. Hence, there are four user control for each order type. If user selects A option from the drop down then Order of type A is created and vica versa. Now below is the List View that contains the List of orders so far created by the user. To Edit any particular order user may double click the list view row. Based on the order type clicked by the user in the listview, the view of that order type opens in edit mode. For example if user selects an order type A from the list view then view for order type A open in edit mode. Please suggest me interaction model for view model's in the scenario discussed above. Please excume me if the query is very basic, since I am new new to MVVM and WPF ,

    Read the article

  • CodeIgniter: Can't load database from within a model

    - by thedp
    Hello, I've written a new model for my CodeIgniter framework. I'm trying to load the database from within the constructor function, but I'm getting the following error: Severity: Notice Message: Undefined property: userdb::$load Filename: models/userdb.php Line Number: 7 Fatal error: Call to a member function database() on a non-object in /var/www/abc/system/application/models/userdb.php on line 7 Here is my model: <?php class userdb extends Model { function __construct() { $this->load->database(); } ?> What am I doing wrong here? Thank you.

    Read the article

  • ASP.NET MVC model binding foreign key relationship

    - by Rory Fitzpatrick
    Is it possible to bind a foreign key relationship on my model to a form input? Say I have a one-to-many relationship between Car and Manufacturer. I want to have a form for updating Car that includes a select input for setting Manufacturer. I was hoping to be able to do this using the built-in model binding, but I'm starting to think I'll have to do it myself. My action method signature looks like this: public JsonResult Save(int id, [Bind(Include="Name, Description, Manufacturer")]Car car) The form posts the values Name, Description and Manufacturer, where Manufacturer is a primary key of type int. Name and Description get set properly, but not Manufacturer, which makes sense since the model binder has no idea what the PK field is. Does that mean I would have to write a custom IModelBinder that it aware of this? I'm not sure how that would work since my data access repositories are loaded through an IoC container on each Controller constructor.

    Read the article

  • MVC: Model View Controller -- does the View call the Model?

    - by Gary Green
    I've been reading about MVC design for a while now and it seems officially the View calls objects and methods in the Model, builds and outputs a view. I think this is mainly wrong. The Controller should act and retrieve/update objects inside the Model, select an appropriate View and pass the information to it so it may display. Only crude and rudiementary PHP variables/simple if statements should appear inside the View. If the View gets the information it needs to display from the Model, surely there will be a lot of PHP inside the View -- completely violating the point of seperating presentation logic.

    Read the article

  • Filtering model results for Django admin select box

    - by blcArmadillo
    I just started playing with Django today and so far am finding it rather difficult to do simple things. What I'm struggling with right now is filtering a list of status types. The StatusTypes model is: class StatusTypes(models.Model): status = models.CharField(max_length=50) type = models.IntegerField() def __unicode__(self): return self.status class Meta: db_table = u'status_types' In one admin page I need all the results where type = 0 and in another I'll need all the results where type = 1 so I can't just limit it from within the model. How would I go about doing this?

    Read the article

  • Codeigniter: Retrieving a variable from Model to use in a Controller

    - by Craig Ward
    Hi, I bet this is easy but been trying for a while and can't seem to get it to work. Basically I am setting up pagination and in the model below I want to pass $total_rows to my controller so I can add it to the config like so '$config['total_rows'] = $total_rows;'. function get_timeline_filter($per_page, $offset, $source) { $this->db->where('source', $source); $this->db->order_by("date", "desc"); $q = $this->db->get('timeline', $per_page, $offset); $total_rows = $this->db->count_all_results(); if($q->num_rows() >0) { foreach ($q->result() as $row) { $data[] = $row; } return $data; } } I understand how to pass things form the Controller to the model using $this->example_model->example($something); but not sure how to get a variable from the model?

    Read the article

  • Specialization hierarchy in a domain-model

    - by devoured elysium
    I'm trying to make the domain model of a management system. I have the following kinds of persons in this system: employee manager top mananger I decided to define a User, from where employee, manager and top manager will specialize from. What I don't know is what kind of specialization hierarchy I should choose from. I thought of two ways: or Which might be preferable and why? As a long time coder, every time I try to do a domain-model, I have to fight against the idea of trying to think in how I'm going to code this. From what I've understood, I should not think about those matters in the domain-model, only in object relationships. I don't have to think of code duplication or any of these kind of details here, so I can't really pick any of the options over the other. Thanks

    Read the article

  • QAbstractTableModel as a model for one QTableView and few QListViews

    - by ??????
    community. Briefly. I wrote usual model over QAbstractTableModel and using it in usual way for QTableView. But I think I need to use some columns of this model for the few QListViews in QWizard to fill main table in the right way (for user). For example: use the column2 as the QListView's model on the page1 of the wizard; column3 for page2 for its QListView etc. Please, help me to understand just two things: Am I on the right way? If yes then how can I make it simply and explicitly?

    Read the article

  • ASP.Net Layered app - Share Entity Data Model amongst layers

    - by Chris Klepeis
    How can I share the auto-generated entity data model (generated object classes) amongst all layers of my C# web app whilst only granting query access in the data layer? This uses the typical 3 layer approach: data, business, presentation. My data layer returns an IEnumerable<T> to my business layer, but I cannot return type T to the presentation layer because I do not want the presentation layer to know of the existence of the data layer - which is where the entity framework auto-generated my classes. It was recommended to have a seperate layer with just the data model, but I'm unsure how to seperate the data model from the query functionality the entity framework provides.

    Read the article

  • Rails - building an absolute url in a model's virtual attribute without url helper

    - by Nick
    I have a model that has paperclip attachments. The model might be used in multiple rails apps I need to return a full (non-relative) url to the attachment as part of a JSON API being consumed elsewhere. I'd like to abstract the paperclip aspect and have a simple virtual attribute like this: def thumbnail_url self.photo.url(:thumb) end This however only gives me the relative path. Since it's in the model I can't use the URL helper methods, right? What would be a good approach to prepending the application root url since I don't have helper support? I would like to avoid hardcoding something or adding code to the controller method that assembles my JSON. Thank you

    Read the article

  • How to pass parameters to report model in Reporting Services

    - by savras
    I'm developing report in RS that show top N customers based on some criteria. It also allows to select number of customers and period of time. Is it possible to do it by using report model? Thing that it seems to be difficult is how to pass parameters determined by user. Another thing that in my oppinion is very disappointing is that i cannot use SQL query as dataset query, because it uses odd and elaborate XML. Although report model items seem to map its fields to query or table fields. I m concerning using report models because i need to provide uniform data model (the same tables and fields) for more or less different database schemas. It would be very nice if somebody would explain what can be done with report models and what can not.

    Read the article

  • dynamic model is not loading fields

    - by Toby Justus
    I am using a dynamic model found on the forum of sencha. function modelFactory(name, fields) { alert(fields); return Ext.define(name, { extend: 'Ext.data.Model', fields: fields }); } I placed the alert(fields) to check what happens with the field because it was not working. I get this: [object Object],[object Object],[object Object] How can i change this into a correct way to use it in the fields? Is there a way to check if the model has been created? With Firebug or something? EDIT: i get this in firebug: [Object { name="ccuDesignation", type=null}, Object { name="wanNumber", type=null}, Object { name="carrierName", type=null}, Object { name="dataPackageName", type=null}, Object { name="simIccid", type=null}, Object { name="expiryTime", type=null}, Object { name="bytesRx", type=null}, Object { name="bytesTx", type=null}]

    Read the article

  • Problem with altering model attributes in controller

    - by SpawnCxy
    Hi all, Today I've got a problem when I tried using following code to alter the model attribute in the controller function userlist($trigger = 1) { if($trigger == 1) { $this->User->useTable = 'betausers'; //'betausers' is completely the same structure as table 'users' } $users = $this->User->find('all'); debug($users); } And the model file is class User extends AppModel { var $name = "User"; //var $useTable = 'betausers'; function beforeFind() //only for debug { debug($this->useTable); } } The debug message in the model showed the userTable attribute had been changed to betausers.And It was supposed to show all records in table betausers.However,I still got the data in the users,which quite confused me.And I hope someone can show me some directions to solve this problem. Regards

    Read the article

  • Rails Model for Playlist that can contain tracks and albums using polymorphism

    - by philk
    I struggle to find a model how to store a playlist with different type of items on it in Rails. Consider I have class Track end class Album has_many :tracks end class PlaylistItem belongs_to :playable belongs_to :playlist end class Playable belongs_to :playable, :polymorph => true end class Playlist has_many :playlist_items end I think I can use a polymorphic model "Playable" here since the Playlist can contain Tracks, Albums and maybe in the future also Movies. Also I would like to use STI for Track and Albums since they share some common attributes like title and length but also have totally different attributes. I modeled it like described here but it does not work. Anybody any idea how to model a Playlist that can contain many items of different kind?

    Read the article

  • Can I change the datsource of report model at runtime

    - by Manab De
    I've some adhoc reports developed on some report models which are published on Report Server (we're using SSRS 2008). Everything is running well. Now in our production environment we've near about forty (40) customers who have their own database (each have the same table structures and other database objects). Now the challenge is whenever a customer will log into the report server using windows authentication and trying to view those reports we need to get the SQL data from the proper database only. Reports are designed using the report model and each model has a valid data source which is connected to particular database. We can create forty separate data sources each will be connected to specific database. My question is, is there any way through which we can change the report model data source name dynamically or during runtime based on the customer name so that during execution of the report, SSRS would fetch the data from the correct database but not from any other database. Please help me.

    Read the article

  • Exposing a "dumbed-down", read-only instance of a Model in GAE

    - by Blixt
    Does anyone know a clever way, in Google App Engine, to return a wrapped Model instance that only exposes a few of the original properties, and does not allow saving the instance back to the datastore? I'm not looking for ways of actually enforcing these rules, obviously it'll still be possible to change the instance by digging through its __dict__ etc. I just want a way to avoid accidental exposure/changing of data. My initial thought was to do this (I want to do this for a public version of a User model): class ReadOnlyUser(db.Model): display_name = db.StringProperty() @classmethod def kind(cls): return 'User' def put(self): raise SomeError() Unfortunately, GAE maps the kind to a class early on, so if I do ReadOnlyUser.get_by_id(1) I will actually get a User instance back, not a ReadOnlyUser instance.

    Read the article

  • How to send complete POST to Model in Code Igniter

    - by Constant M
    Hi there, What would be the best way to send a complete post to a model in Code Igniter? Methods I know are as follow: Name form elements as array, eg. <input type="text" name="contact[name]"> <input type="text" name="contact[surname]"> and then use: $this->Model_name->add_contact($this->input->post('contact')); The other would be to add each element to an array and then send it to the model as such: <input type="text" name="name"> <input type="text" name="surname"> and $contact_array = array('name' => $this->input->post('name'), 'surname' => $this->input->post('surname')); $this->Model_name->add_contact($this->input->post('contact')); Which one of these would be best practice, and is there a way to directly send a whole POST to a model (or a whole form maybe?)

    Read the article

  • CoreData Model Objects for API

    - by theiOSguy
    I am using CoreData in my application. I want to abstract out all the CoreData related stuff as an API so that the consume can use the API instead of directly using CoreData and its generated model objects. CoreData generates the managed objects model as following @interface Person : NSManagedObject @end I want to define my API for example MyAPI and it has a function called as createPerson:(Person*)p; So the consumer of this createPerson API needs to create a Person data object (like POJO in java world) and invoke this API. But I cannot create Person object using Person *p = [Person alloc] init] because the designated initializer for this Person model created by CoreData does not allow this type of creation. So should I define corresponding user facing data object may be PersonDO and this API should take that instead to carry the data into the API implementation? Is my approach right? Any expert advise if design the API this way is a good design pattern?

    Read the article

  • Automated “ubuntu-12.04.1-server-amd64” OS installation on physical machine

    - by user285336
    We are using Physical server and are in process of Automated “ubuntu-12.04.1-server-amd64” OS installation on it. There are two HDD for OS installation purpose and there are RAID1 relation between them. This setup has been done through BIOS. The kickstart configuration file looks like this: #Generated by Kickstart Configurator #platform=AMD64 or Intel EM64T #System language lang en_US #Language modules to install langsupport en_US #System keyboard keyboard us #System mouse mouse #System timezone timezone Asia/Dili #Root password rootpw --iscrypted $1$Yl1QJyta$KzIT.kq3i9E5XaiQKcUJn/ #Initial user user ankit --fullname "Ankit" --iscrypted --password $1$c6Yflpea$pi1QQ59/jgywmGwBv25z3/ #Reboot after installation reboot #Use text mode install text #Install OS instead of upgrade install #Use Web installation url --url my_repo_location #System bootloader configuration bootloader --location=mbr #Clear the Master Boot Record zerombr yes #Partition clearing information clearpart --all --initlabel #Disk partitioning information part /boot --fstype ext4 --size 100 --ondisk sda part / --fstype ext4 --size 10000 --ondisk sda part /var --fstype ext4 --size 10000 --ondisk sda part swap --size 1024 --ondisk sdb #System authorization infomation auth --useshadow --enablemd5 #Network information network --bootproto=dhcp --device=eth0 #Firewall configuration firewall --enabled --trust=eth0 --http --ftp --ssh --telnet --smtp #X Window System configuration information xconfig --depth=8 --resolution=640x480 --defaultdesktop=GNOME But I am getting the below error : No root file system is defined Please suggest on this. Do we need to do any modification in kickstart configuration file. Any help in this regard will be very helpful for us. The automated Ubuntu OS installation is successful in Virtual Machine(VM) with the above ks.cfg (kickstart configuration file ) but failing in case of physical machine. Please suggest on this and if possible provide the new ks.cfg file to resolve above problem. Thanks & Regards, Rajesh Prasad

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >