Search Results

Search found 3214 results on 129 pages for 'city simulation'.

Page 14/129 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Very Cool &ndash; Miami 311 System for tracking citizen service requests (Windows Azure, Silverlight

    - by Jim Duffy
    Having grown up in South Florida this short, but very enlightening, video explaining how the City of Miami has implemented a 311 citizen service request system using Windows Azure, Silverlight and Bing Maps definitely caught my attention. Miami311 The Miami311 System is a Windows Azure/Silverlight-based solution which enables City of Miami citizens report and track issues reported to city management. The system uses Bing Maps to plot the location and relevant information about each issue reported. Citizens now have the ability to easily see the status of the issue without having to call the city office. What I found interesting were a couple of benefits that a metropolitan area such as Miami can take advantage of in Windows Azure cloud-based solution. For the city of Miami, both benefits center around the weather. Of course the threat of a hurricane is a real issue in South Florida and what better way to make sure your site stays up during a hurricane then to have the site hosted far away from the eye of the storm. Using a Windows Azure cloud-based architecture the City of Miami is able to host the application within the Microsoft data centers safely away from any hurricane passing through South Florida. The second benefit is the inherent scalability of a Windows Azure based solution. During a severe weather event like thunderstorms or even worse, a hurricane, downed trees and power lines are a commonly reported problem. Being able to quickly scale up the computing resources required to handle the spike in citizens reporting these types of problems on the site is a huge benefit. Once the weather event has passed and downed tree reports begin to subside they can quickly reverse the process and scale the system back down to pre-storm levels. It’s kind of day-to-day kind of stuff but very cool stuff nonetheless. Have a day. :-|

    Read the article

  • Best way to lay-out the website when sections of it are almost identical

    - by Linas
    so, I have a minisite for the mobile application that I did. The mobile application is a public transport (transit) schedule viewer for a particular city (let's call it Foo), and I'm trying to sell it via that minisite. I publish that minisite in www.myawesomeapplication.com/foo/. It has the usual "standard" subpages, like "About", "Compatible phones", "Contact", etc. Now, I have decided to create analogue mobile application for other cities, Bar and Baz. These mobile applications (products) would be almost identical to the one for the Foo city, thus the minisites for those would (should) look very similar too (except for some artwork and Foo = Bar replacement). The question is: what do you think would be the most logical way to lay-out the website in this situation, both from the business and search engine perspective? In other words, should I just duplicate the /foo/ website to /bar/ and /baz/, or would it be better to try to create a single website under root path (/)? I don't want search engine penalties for almost-duplicate information under /foo/, /bar/ and /baz/, and also I don't want a messy, non-localized website (I guess the user is more likely to buy something if he/she sees "This-and-that is the application for NYC, the city you live in", not "This-and-that is the application for city A, city B, ..., NYC, ..., and city Z.")

    Read the article

  • Cannot implicitly convert type 'System.Linq.IQueryable<int>' to 'int?'

    - by Aneef
    Hi this is my code var cityList = from country in doc.Element("result").Element("cities").Descendants("city") select new { Name = country.Element("name").Value, Code = country.Element("code").Value, CountryCode = int.Parse(country.Element("countrycode").Value) }; foreach(var citee in cityList) { City city = new City(); city.CountryID = from cnt in db.Countries where cnt.DOTWInternalID == citee.CountryCode select cnt.ID; } Im getting an error on the second query as the title of this post, i tried converting to int, to nullable int nothing worked? help me guys Thanks,

    Read the article

  • Linq Projection Question

    - by Micah
    I'm trying to do the following: from c in db.GetAllContactsQuery() select new { ID= c.ID, LastName = c.LastName, FirstName = c.FirstName, Email = c.Email, City =c.City+" "+c.State } The issue i'm running into is that if c.City or c.State are null, the City property returns null. How can I put a function right beside that City= declaration?

    Read the article

  • Htaccess rewrite rule .aspx to .php

    - by Markus Ossi
    Background: I have a website that has been built with ASP.NET 2.0 and is on Windows hosting. I now have to rewrite my site in PHP and move it into Linux hosting. I have a lot of incoming links to my site from around the web that point directly into the old .aspx-pages. The site itself is very simple, one dynamic page and five static ones. I saved the static .aspx pages as .php-pages and rewrote the dynamic page in PHP. The dynamic page is called City.aspx and I have written it in PHP and it is now called City.php. On my old Windows hosting, I used ASP.NET's URL mapping for friendly URL. For example, incoming URL request for Laajakaista/Ypaja.aspx was mapped into City.aspx?CityID=981. My goal: To redirect all human visitors and search engines looking for the old .aspx pages into the new .php pages. I am thinking that the easiest way to redirect visitors into new pages will be by making a redirect, where all requests for .aspx-files will be redirected into .php filetypes. So, if someone asks for MYSITE/City.aspx?CityID=5, they will be taken into MYSITE/City.php?CityID=5 instead. However, I am having a lot of trouble getting this to work. So far this is what I have found: rewriterule ^([.]+)\.aspx$ http://www.example.com/$1.php [R=301,L] However, I think this can not handle the parameters after the filetype and I am also not quite sure what to put on front. To make things a bit more complicated, at my previous site I used friendly URL's so that I had a huge mapping file with mappings like this: <add url="~/Laajakaista/Ypaja.aspx" mappedUrl="~/City.aspx?CityID=981" /> <add url="~/Laajakaista/Aetsa.aspx" mappedUrl="~/City.aspx?CityID=988" /> <add url="~/Laajakaista/Ahtari.aspx" mappedUrl="~/City.aspx?CityID=989" /> <add url="~/Laajakaista/Aanekoski.aspx" mappedUrl="~/City.aspx?CityID=992" /> I tried to make a simple redirect like this: Redirect 301 Laajakaista/Aanekoski.aspx City.php?CityID=992 but was not able to get it to work. I ended up with an internal server error and a 50k .htaccess-file... Any help is greatly appreciated.

    Read the article

  • How to add an additional column in a table by comparing the values in a different column

    - by S-Man
    I have a table with the following records id name city 1 aaa NY 2 bbb NY 3 ccc LA 4 ddd LA 5 eee NY I want the table with an additional column by comparing the 'city' column. The values in the col4 should have '1' for every unique value in 'city' column and '0' for the repeating values in 'city' column. id name city col4 1 aaa NY 1 2 bbb NY 0 3 ccc LA 1 4 ddd LA 0 5 eee NY 0 I hope to get some help. Thanks

    Read the article

  • PHP matching a string

    - by John Jones
    Hi, I have an Indian company data set and need to extract the City and Zip from the address field: Address Field Example: Gowripuram West, Sengunthapuram Post, Near L.G.B., Karur, Tamilnadu, Karur - 639 002, India As you can see the City is Karur and the zip is followed after the - (hyphen). I need the PHP code to match [city] - [zip] Not sure how to do this I can find the Zip after the Hypen but not sure how to find the City, please note the City can be 2 words. Cheers for your time./ J

    Read the article

  • writing an Dynamic query in sqlserver

    - by prince23
    hi, DECLARE @sqlCommand varchar(1000) DECLARE @columnList varchar(75) DECLARE @city varchar(75) DECLARE @region varchar(75) SET @columnList = 'first_name, last_name, city' SET @city = '''London''' SET @region = '''South''' SET @sqlCommand = 'SELECT ' + @columnList + ' FROM dbo.employee WHERE City = ' + @city and 'region = '+@region --and 'region = '+@region print(@sqlCommand) EXEC (@sqlCommand) when i run this command i get an error Msg 156, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'and'. and help would great thank you

    Read the article

  • LINQ Query returns false when it should be true.

    - by deliriousDev
    I have the following LINQ query written by a former developer and it isn't working when it should. public bool IsAvailable(Appointment appointment) { var appointments = _appointmentRepository.Get; var shifts = _scheduleRepository.Get; var city = _customerRepository.Find(appointment.CustomerId).City ?? appointment.Customer.City; const int durationHour = 1; DateTime scheduledEndDate = appointment.ScheduledTime.Add(new TimeSpan(durationHour, 0, 0)); var inWorkingHours = shifts .Where(x => //Check if any available working hours x.Employee.City == city && x.ShiftStart <= appointment.ScheduledTime && x.ShiftEnd >= scheduledEndDate && //check if not booked yet !appointments .Where(a => (appointment.Id == 0 || a.Id != appointment.Id) && a.Employee.Id == x.Employee.Id && ( (a.ScheduledTime <= appointment.ScheduledTime && appointment.ScheduledTime <= EntityFunctions.AddHours(a.ScheduledTime, durationHour)) || (a.ScheduledTime <= scheduledEndDate && scheduledEndDate <= EntityFunctions.AddHours(a.ScheduledTime, durationHour)) )) .Select(a => a.Employee.Id) .Contains(x.Employee.Id) ); if (inWorkingHours.Any()) { var assignedEmployee = inWorkingHours.FirstOrDefault().Employee; appointment.EmployeeId = assignedEmployee.Id; appointment.Employee = assignedEmployee; return true; } return false; } The query is suppose to handle the following scenarios Given An Appointment With A ScheduledTime Between A ShiftStart and ShiftEnd time But Does not match any employees in same city - (Return true, Assign as "Unassigned") Given An Appointment With A ScheduledTime Between A ShiftStart and ShiftEnd time AND Employee for that shift is in the same city as the customer (Return True AND Assign to the employee) If the customer is NOT in the same city as an employee we assign the appointment as "Unassigned" as along as the scheduledTime is within an of the employees shift start/end times If the customer is in the same city as an employee we assign the appointment to one of the employees (firstOrdefault) and occupy that timeslot. Appointments CAN NOT overlap (Assigned Ones). Unassigned can't overlap each other. This query use to work (I've been told). But now it doesn't and I have tried refactoring it and various other paths with no luck. I am now on week two and just don't know where the issue in the query is or how to write it. Let me know if I need to post anything further. I have verified appointments, shifts, city all populate with valid data so the issue doesn't appear to be with null or missing data.

    Read the article

  • What is wrong with this SimPy installation?

    - by dmindreader
    Alright, I have tried a bunch of times the python setup.py install command from my command prompt, and this is what I'm getting: SCREEN And when trying this: from SimPy.Simulation import * on Idle, I get this: Traceback (most recent call last): File "C:/Python30/pruebas/prueba1", line 1, in <module> from SimPy.Simulation import * File "C:\Python30\SimPy\Simulation.py", line 320 print 'SimPy.Simulation %s' %__version__, ^ SyntaxError: invalid syntax >>>

    Read the article

  • Accessing child collection in query

    - by Gokul
    I am populating a list using List<Country> countries = new List<Country> { new Country() { CountryID = "US", City = new List<City> { new City() { CountryID = "US", CityName="dfdsf", sqkm = 2803 } } }; and so on How to access sqkm in the following query? var countryQuery = countries .Select(c => new { Id = c.CountryId, Area = c.City.sqkm???}); c.city.sqkm gives compilation error...how to modify query

    Read the article

  • WebGrid Helper and Complex Types

    - by imran_ku07
        Introduction:           WebGrid helper makes it very easy to show tabular data. It was originally designed for ASP.NET Web Pages(WebMatrix) to display, edit, page and sort tabular data but you can also use this helper in ASP.NET Web Forms and ASP.NET MVC. When using this helper, sometimes you may run into a problem if you use complex types in this helper. In this article, I will show you how you can use complex types in WebGrid helper.       Description:             Let's say you need to show the employee data and you have the following classes,   public class Employee { public string Name { get; set; } public Address Address { get; set; } public List<string> ContactNumbers { get; set; } } public class Address { public string City { get; set; } }               The Employee class contain a Name, an Address and list of ContactNumbers. You may think that you can easily show City in WebGrid using Address.City, but no. The WebGrid helper will throw an exception at runtime if any Address property is null in the Employee list. Also, you cannot directly show ContactNumbers property. The easiest way to show these properties is to add some additional properties,   public Address NotNullableAddress { get { return Address ?? new Address(); } } public string Contacts { get { return string.Join("; ",ContactNumbers); } }               Now you can easily use these properties in WebGrid. Here is the complete code of this example,  @functions{ public class Employee { public Employee(){ ContactNumbers = new List<string>(); } public string Name { get; set; } public Address Address { get; set; } public List<string> ContactNumbers { get; set; } public Address NotNullableAddress { get { return Address ?? new Address(); } } public string Contacts { get { return string.Join("; ",ContactNumbers); } } } public class Address { public string City { get; set; } } } @{ var myClasses = new List<Employee>{ new Employee { Name="A" , Address = new Address{ City="AA" }, ContactNumbers = new List<string>{"021-216452","9231425651"}}, new Employee { Name="C" , Address = new Address{ City="CC" }}, new Employee { Name="D" , ContactNumbers = new List<string>{"045-14512125","21531212121"}} }; var grid = new WebGrid(source: myClasses); } @grid.GetHtml(columns: grid.Columns( grid.Column("NotNullableAddress.City", header: "City"), grid.Column("Name"), grid.Column("Contacts")))                    Summary:           You can use WebGrid helper to show tabular data in ASP.NET MVC, ASP.NET Web Forms and  ASP.NET Web Pages. Using this helper, you can also show complex types in the grid. In this article, I showed you how you use complex types with WebGrid helper. Hopefully you will enjoy this article too.  

    Read the article

  • How do you do HTML form testing without real user input simulation ?

    - by justjoe
    this question is like this one, except it's for PHP testing via browser. It's about testing your form input. Right now, i have a form on a single page. It has 12 input boxes. Every time i test the form, i have write those 12 input boxes in my browser. i know it's not a specific coding question. This question is more about how to do direct testing on your form So, how to do recursive testing without consuming too much of your time ?

    Read the article

  • Storing simulation results in a persistent manner for Python?

    - by Az
    Background: I'm running multiple simuations on a set of data. For each session, I'm allocating projects to students. The difference between each session is that I'm randomising the order of the students such that all the students get a shot at being assigned a project they want. I was writing out some of the allocations in a spreadsheet (i.e. Excel) and it basically looked like this (tiny snapshot, actual table extends to a few thousand sessions, roughly 100 students). | | Session 1 | Session 2 | Session 3 | |----------|-----------|-----------|-----------| |Stu1 |Proj_AA |Proj_AB |Proj_AB | |----------|-----------|-----------|-----------| |Stu2 |Proj_AB |Proj_AA |Proj_AC | |----------|-----------|-----------|-----------| |Stu3 |Proj_AC |Proj_AC |Proj_AA | |----------|-----------|-----------|-----------| Now, the code that deals with the allocation currently stores a session in an object. The next time the allocation is run, the object is over-written. Thus what I'd really like to do is to store all the allocation results. This is important since I later need to derive from the data, information such as: which project Stu1 got assigned to the most or perhaps how popular Proj_AC was (how many times it was assigned / number of sessions). Question(s): What methods can I possibly use to basically store such session information persistently? Basically, each session output needs to add itself to the repository after ending and before beginning the next allocation cycle. One solution that was suggested by a friend was mapping these results to a relational database using SQLAlchemy. I kind of like the idea since this does give me an opportunity to delve into databases. Now the database structure I was recommended was: |----------|-----------|-----------| |Session |Student |Project | |----------|-----------|-----------| |1 |Stu1 |Proj_AA | |----------|-----------|-----------| |1 |Stu2 |Proj_AB | |----------|-----------|-----------| |1 |Stu3 |Proj_AC | |----------|-----------|-----------| |2 |Stu1 |Proj_AB | |----------|-----------|-----------| |2 |Stu2 |Proj_AA | |----------|-----------|-----------| |2 |Stu3 |Proj_AC | |----------|-----------|-----------| |3 |Stu1 |Proj_AB | |----------|-----------|-----------| |3 |Stu2 |Proj_AC | |----------|-----------|-----------| |3 |Stu3 |Proj_AA | |----------|-----------|-----------| Here, it was suggested that I make the Session and Student columns a composite key. That way I can access a specific record for a particular student for a particular session. Or I can merely get the entire allocation run for a particular session. Questions: Is the idea a good one? How does one implement and query a composite key using SQLAlchemy? What happens to the database if a particular student is not assigned a project (happens if all projects that he wants are taken)? In the code, if a student is not assigned a project, instead of a proj_id he simply gets None for that field/object. I apologise for asking multiple questions but since these are closely-related, I thought I'd ask them in the same space.

    Read the article

  • Python/Biophysics- Trying to code a simple stochastic simulation!

    - by user359597
    Hey guys- I'm trying to figure out what to make of the following code- this is not the clear, intuitive python I've been learning. Was it written in C or something then wrapped in a python fxn? The code I wrote (not shown) is using the same math, but I couldn't figure out how to write a conditional loop. If anyone could explain/decipher/clean this up, I'd be really appreciative. I mean- is this 'good' python- or does it look funky? I'm brand new to this- but it's like the order of the fxns is messed up? I understand Gillespie's- I've successfully coded several simpler simulations. So in a nutshell- good code-(pythonic)? order? c? improvements? am i being an idiot? The code shown is the 'answer,' to the following question from a biophysics text (petri-net not shown and honestly not necessary to understand problem): "In a programming language of your choice, implement Gillespie’s First Reaction Algorithm to study the temporal behaviour of the reaction A---B in which the transition from A to B can only take place if another compound, C, is present, and where C dynamically interconverts with D, as modelled in the Petri-net below. Assume that there are 100 molecules of A, 1 of C, and no B or D present at the start of the reaction. Set kAB to 0.1 s-1 and both kCD and kDC to 1.0 s-1. Simulate the behaviour of the system over 100 s." def sim(): # Set the rate constants for all transitions kAB = 0.1 kCD = 1.0 kDC = 1.0 # Set up the initial state A = 100 B = 0 C = 1 D = 0 # Set the start and end times t = 0.0 tEnd = 100.0 print "Time\t", "Transition\t", "A\t", "B\t", "C\t", "D" # Compute the first interval transition, interval = transitionData(A, B, C, D, kAB, kCD, kDC) # Loop until the end time is exceded or no transition can fire any more while t <= tEnd and transition >= 0: print t, '\t', transition, '\t', A, '\t', B, '\t', C, '\t', D t += interval if transition == 0: A -= 1 B += 1 if transition == 1: C -= 1 D += 1 if transition == 2: C += 1 D -= 1 transition, interval = transitionData(A, B, C, D, kAB, kCD, kDC) def transitionData(A, B, C, D, kAB, kCD, kDC): """ Returns nTransition, the number of the firing transition (0: A->B, 1: C->D, 2: D->C), and interval, the interval between the time of the previous transition and that of the current one. """ RAB = kAB * A * C RCD = kCD * C RDC = kDC * D dt = [-1.0, -1.0, -1.0] if RAB > 0.0: dt[0] = -math.log(1.0 - random.random())/RAB if RCD > 0.0: dt[1] = -math.log(1.0 - random.random())/RCD if RDC > 0.0: dt[2] = -math.log(1.0 - random.random())/RDC interval = 1e36 transition = -1 for n in range(len(dt)): if dt[n] > 0.0 and dt[n] < interval: interval = dt[n] transition = n return transition, interval if __name__ == '__main__': sim()

    Read the article

  • is there such a thing as xsl:fo reporting or xsl:fo simulation?

    - by topmulch
    Hi, I am trying to determine if MY xsl:fo generated PDF file will exceed one page or not, without actually generating the output. We use Apache-FOP 0.95 on our server, and the XML data is being generated using a PHP DOMDocument class before being passed onto an XSL-FO template. My question: Are there PHP libraries out there that can simulate xsl:fo output and send me reports that I can use in my application? Alternatively, is there a way for the Apache FOP itself (or sibling Java app) that sends reports without actually generating a file? I have been reading the FOP documentation, and aside from some things I can not fully understand, I have not been able to find a way to do that from within FOP. Any advice is much appreciated.

    Read the article

  • PHP, javascript, single quote problems with IE when passing variable from ajax post to javascript fu

    - by Mattis
    Hi! I have been trying to get this to work for a while, and I suspect there's an easy solution that I just can't find. My head feels like jelly and I would really appreciate any help. My main page.php makes a .post() to backend.php and fetches a list of cities which it echoes in the form of: <li onclick="script('$data');">$data</li> The list is fetched and put onto the page via .html(). My problem occurs when $data has a single quote in it. backend.php passes the variable just fine to page.php but when i run html() it throws a javascript error (in IE, not FF obviously); ')' is expected IE parses the single quote and messes up the script()-call. I've been trying to rebuild the echoed string in different ways, escaping the 's on the php side and/or on the javascript side - but in vain. Do I have to review the script in total? page.php $.post("backend.php", {q: ""+str+""}, function(data) { if(data.length >0) { $('#results').html(data); } backend.php while ($row = $q->fetch()) { $city = $row['City']; // $city = addslashes($row['City']); // $city = str_replace("'","&#39;",$row['City']); echo "<li onclick=\"script('$city');\">".$city."</li>"; }

    Read the article

  • nested attributes with polymorphic has_one model

    - by Millisami
    I am using accepts_nested_attributes_for with the has_one polymorphic model in rails 2.3.5 Following are the models and its associations: class Address < ActiveRecord::Base attr_accessible :city, :address1, :address2 belongs_to :addressable, :polymorphic => true validates_presence_of :address1, :address2, :city end class Vendor < ActiveRecord::Base attr_accessible :name, :address_attributes has_one :address, :as => :addressable, :dependent => :destroy accepts_nested_attributes_for :address end This is the view: - form_for @vendor do |f| = f.error_messages %p = f.label :name %br = f.text_field :name - f.fields_for :address_attributes do |address| = render "shared/address_fields", :f => address %p = f.submit "Create" This is the partial shared/address_fields.html.haml %p = f.label :city %br= f.text_field :city %span City/Town name like Dharan, Butwal, Kathmandu, .. %p = f.label :address1 %br= f.text_field :address1 %span City Street name like Lazimpat, New Road, .. %p = f.label :address2 %br= f.text_field :address2 %span Tole, Marg, Chowk name like Pokhrel Tole, Shanti Marg, Pako, .. And this is the controller: class VendorsController < ApplicationController def new @vendor = Vendor.new end def create @vendor = Vendor.new(params[:vendor]) if @vendor.save flash[:notice] = "Vendor created successfully!" redirect_to @vendor else render :action => 'new' end end end The problem is when I fill in all the fileds, the record gets save on both tables as expected. But when I just the name and city or address1 filed, the validation works, error message shown, but the value I put in the city or address1, is not persisted or not displayed inside the address form fields? This is the same case with edit action too. Though the record is saved, the address doesn't show up on the edit form. Only the name of the Client model is shown. Actually, when I look at the log, the address model SQL is not queried even at all.

    Read the article

  • jqtransform form selector (onchange) problem !!!!

    - by Newbie
    I'm styling a form with Jqtransform script. The form includes a selector which enlist some cities, when i click a one, it should update the selector below it with some locations within that city. here is the code of the selector <select name="city" id="city" class="wide" onchange="populateDestrict(this)"> It was working fine with default style , but after applying JQ, it lost it's functionality I asked a question before here LINK and i did as Dormilich did by writing: $(function() { $("form.jqtransform").jqTransform(); $("#city").change(populateDestrict(this)); }); But it didn't work ! here is also the code of the function if it helps <script language="javascript"> function populateDestrict(obj){ var city=obj.value; if(city!=""){ $.post('city_state.php',{ city: city},function(xml){ $("#state").removeOption(/./); $("district",xml).each(function() { $("#state").addOption($("key",this).text(), $("value",this).text()); }); }); } } </script> Any help people ???????? Thanks

    Read the article

  • JPA - Entity design problem

    - by Yatendra Goel
    I am developing a Java Desktop Application and using JPA for persistence. I have a problem mentioned below: I have two entities: Country City Country has the following attribute: CountryName (PK) City has the following attribute: CityName Now as there can be two cities with same name in two different countries, the primaryKey for City table in the datbase is a composite primary key composed of CityName and CountryName. Now my question is How to implement the primary key of the City as an Entity in Java @Entity public class Country implements Serializable { private String countryName; @Id public String getCountryName() { return this.countryName; } } @Entity public class City implements Serializable { private CityPK cityPK; private Country country; @EmbeddedId public CityPK getCityPK() { return this.cityPK; } } @Embeddable public class CityPK implements Serializable { public String cityName; public String countryName; } Now as we know that the relationship from Country to City is OneToMany and to show this relationship in the above code, I have added a country variable in City class. But then we have duplicate data(countryName) stored in two places in the City class: one in the country object and other in the cityPK object. But on the other hand, both are necessary: countryName in cityPK object is necessary because we implement composite primary keys in this way. countryName in country object is necessary because it is the standard way of showing relashionship between objects. How to get around this problem?

    Read the article

  • JSON feed to Java Object

    - by mnml
    Hi, I would like to know if there is a webpage/software that can "translate" a Json feed object to a Java object with attributes. For example : { 'firstName': 'John', 'lastName': 'Smith', 'address': { 'streetAddress': '21 2nd Street', 'city': 'New York' } } Would become: class Person { private String firstName; private String lastName; private Address address; public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public Address getAddress() { return address; } public void setFirstName(String firstName) { this.firstName = firstName; } public void setLastName(String lastName) { this.lastName = lastName; } public void setAddress(Address address) { this.address = address; } public String toString() { return String.format("firstName: %s, lastName: %s, address: [%s]", firstName, lastName, address); } } class Address { private String streetAddress; private String city; public String getStreetAddress() { return streetAddress; } public String getCity() { return city; } public void setStreetAddress(String streetAddress) { this.streetAddress = streetAddress; } public void setCity(String city) { this.city = city; } public String toString() { return String.format("streetAddress: %s, city: %s", streetAddress, city); } } I'm not asking that because I'm lazy, but the JSON I would like to parse has quite a lot of attribute.

    Read the article

  • mysql to xml (DOM question)

    - by Jerry
    Hello guys I am new to php dom and trying to get the mysql data transfer into xml. My current xml output is like this <markers> <city> <name>Seattle</name> <size>medium</size> <name>New York</name> <size>big</size> <city> <markers> but I want to change it to <markers> <city> <name>Seattle</name> <size>medium</size> <city> <city> <name>New York</name> <size>big</size> </city> <city> <markers> my php $dom=new DOMDocument("1.0"); $node=$dom->createElement("markers"); $parnode=$dom->appendChild($node); $firstElement=$dom->createElement("city"); $parnode->appendChild($firstElement); $getLocationQuery=mysql_query("SELECT * FROM location",$connection); header("Content-type:text/xml"); while($row=mysql_fetch_assoc($getLocationQuery)){ foreach ($row as $fieldName=>$value){ $child=$dom->createElement($fieldName); $value=$dom->createTextNode($value); $child->appendChild($value); $firstElement->appendChild($child); } } I can't figure out how to change my php code. Please help me about it. Thanks a lot.

    Read the article

  • Running a Model::find in for loop in cakephp v1.3

    - by Gaurav Sharma
    Hi all, How can I achieve the following result in cakephp: In my application a Topic is related to category, category is related to city and city is finally related to state in other words: topic belongs to category, category belongs to city , city belongs to state.. Now in the Topic controller's index action I want to find out all the topics and it's city and state. How can I do this. I can easily do this using a custom query ($this-Model-query() function ) but then I will be facing pagination difficulties. I tried doing like this function index() { $this->Topic->recursive = 0; $topics = $this->paginate(); for($i=0; $i<count($topics);$i++) { $topics[$i]['City'] = $this->Topic->Category->City->find('all', array('conditions' => array('City.id' => $topics[$i]['Category']['city_id']))); } $this->set(compact('messages')); } The method that I have adopted is not a good one (running query in a loop) Using the recursive property and setting it to highest value (2) will degrade performance and is not going to yield me state information. How shall I solve this ? Please help Thanks

    Read the article

  • Having an issue with the "this" modifier...

    - by user344246
    I have this method in City class. It should create a new city based on the object which the method is applied to: public City newCity(string newCityName, int dX, int dY) { City c=new City(this); //based on a constructor : City(City c){} c.CityName=newCityName; c.NoOfNeighborhoods=1; c.NumOfResidents=0; c.CityCenter.Move(dX,dY); return c; } CityCenter is of type "Point" which has two fields - x,y. the Move method in Point class is ment to change the CityCenter location. It looks like this: public void Move(int dX, int dY) { this.X = x + dX; this.Y = y + dY; } What happens is that the new object,c and the existing City object are both changed. I think that "this" modifier works on the existing object too... How can I take advantage of the Move method without causing this behavior? Note: this is a closed API, so I can only add private methods to the project.

    Read the article

  • ASP.net User Controls and business entities

    - by Chris
    Hi all, I am currently developing some user controls so that I can use them at several places within a project. One control is a about editing a list of addresses for a customer. Since this needs to be done at several places within the project I want to make it a simple user control. The user control contains a repeater control. By default the repeater displays one address item to be edited. If more addresses need to be added, the user can click on a button to append an additional address to be entered. The user control should work for creating new addresses as well as editing existing ones. The address business entity looks something like this: public class Address { public string Street { get; set; } public City City { get; set; } public Address(string street, City city) { Check.NotNullOrEmpty(street); Check.NotNull(city); Street = street; City = city; } } As you can see an address can only be instantiated if there is a street and a city. Now my idea was that the user control exposes a collection property called Addresses. The getter of this property collects the addresses from the repeater and return it in a collection. The setter would databind the addresses to be edited to the repeater. Like this: public partial class AddressEditControl : System.Web.UI.UserControl { public IEnumerable<Address> Addresses { get { IList<Address> addresses = new List<Address>(); // collect items from repeater and create addresses foreach (RepeaterItem item in addressRepeater.Items) { // collect values from repeater item addresses.Add(new Address(street, city)); } return addresses; } set { addressRepeater.DataSource = value; addressRepeater.DataBind(); } } } First I liked this approach since it is object oriented makes it very easy to reuse the control. But at some place in my project I wanted to use this control so a user could enter some addresses. And I wanted to pre-fill the street input field of each repeater item since I had that data so the user doesn't need to enter it all by his self. Now the problem is that this user control only accepts addresses in a valid state (since the address object has only one constructor). So I cannot do: IList<Addresses> addresses = new List<Address>(); addresses.Add(new Address("someStreet", null)); // i dont know the city yet (user has to find it out) addressControl.Addresses = addresses; So the above is not possible since I would get an error from address because the city is null. Now my question: How would I create such a control? ;) I was thinking about using an Address DTO instead of a real address, so it can later be mapped to an address. That way I can pass in and out an address collection which addresses don't need to be valid. Or did I misunderstood the way user controls work? Are there any best practices?

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >