Search Results

Search found 10804 results on 433 pages for 'attribute keys'.

Page 114/433 | < Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >

  • How to sort objects in a many-to-many relationship in ruby on rails?

    - by Kenji Kina
    I've been trying to deal with this problem for a couple of hours now and haven't been able to come up with a clean solution. It seems I'm not too good with rails... Anyway, I have the following: In code: class Article < ActiveRecord::Base has_many :line_aspects, :dependent => :destroy has_many :aspects, :through => :line_aspects #plus a name field end class LineAspect < ActiveRecord::Base belongs_to :article belongs_to :aspect end class Aspect < ActiveRecord::Base belongs_to :data_type has_many :line_aspects has_many :articles, :through => :line_aspects end Now, what I would like to do, is to sort these in two steps. First list of Articles by their Articles.name, and then inside sort them by Aspect.name (note, not the middleman). For instance, alphabetically (sorry if the notation is not correct): [{ article => 'Apple', line_aspects => [ {:value => 'red'}, #corresponding to the Attribute with :name => 'color' {:value => 'small'} #corresponding to the Attribute with :name => 'shape' ] },{ article => 'Watermelon', line_aspects => [ {:value => 'green'}, #corresponding to the Attribute with :name => 'color' {:value => 'big'} #corresponding to the Attribute with :name => 'shape' ] }] Again, note that these are ordered by the aspect name (color before shape) instead of the specific values of each line (red before green). (NOTE: My intention is to displaye these in a table in the view) I have not found a good way to do this in rails yet (without resorting to N queries). Can anyone tell me a good way to do it?

    Read the article

  • Can PHP dissect its own syntax?

    - by Nathan Long
    Can PHP dissect its own syntax? For example, I'd like to write a function that takes in an input like $object->attribute and says to itself: OK, he's giving me $foo->bar, which means he must think that $foo is an object that has a property called bar. Before I try accessing bar and potentially get a 'Trying to get property of non-object' error, let me check whether $foo is even an object. The end goal is to echo a value if it is set, and fail silently if not. I want to avoid repetition like this: <input value="<? if(is_object($foo) && is_set($foo->bar)){ echo $foo->bar; }?> "/> ...and to avoid writing a function that does the above, but has to have the object and attribute passed in separately, like this: <input value="<? echoAttribute($foo,'bar') ?>" /> ...but to instead write something which: preserves the object-attribute syntax is flexible: can also handle array keys or regular variables Like this: <input value="<? echoIfSet($foo->bar); ?> /> <input value="<? echoIfSet($baz['buzz']); ?> /> <input value="<? echoIfSet($moo); ?> /> But this all depends on PHP being able to tell me "what kind of thing am I asking for when I say $object->attribute or $array[$key]", so that my function can handle each according to its own type. Is this possible?

    Read the article

  • Reading system.net/mailSettings/smtp from Web.config in Medium trust environment

    - by Carson63000
    Hi, I have some inherited code which stores SMTP server, username, password in the system.net/mailSettings/smtp section of the Web.config. It used to read them like so: Configuration c = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath); MailSettingsSectionGroup settings = (MailSettingsSectionGroup)c.GetSectionGroup("system.net/mailSettings"); return settings.Smtp.Network.Host; But this was failing when I had to deploy to a medium trust environment. So following the answer from this question, I rewrote it to use GetSection() like so: SmtpSection settings = (SmtpSection)ConfigurationManager.GetSection("system.net/mailSettings/smtp"); return settings.Network.Host; But it's still giving me a SecurityException on Medium trust, with the following message: Request for ConfigurationPermission failed while attempting to access configuration section 'system.net/mailSettings/smtp'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared. So I tried this requirePermission attribute, but can't figure out where to put it. If I apply it to the <smtp> node, I get a ConfigurationError: "Unrecognized attribute 'requirePermission'. Note that attribute names are case-sensitive." If I apply it to the <mailSettings> node, I still get the SecurityException. Is there any way to get at this config section programatically under medium trust? Or should I just give up on it and move the setting into <appSettings>?

    Read the article

  • Intellisense for custom config section problem with namespaces

    - by Quick Joe Smith
    I have just rolled a custom configuration section, created an accompanying schema document for Intellisense and added it to the Web.config's Schemas property as per Michael Stum's answer to another similar question. Unfortunately, and possibly due to me creating the XSD by hand with limited knowledge, the Intellisense relies on an xmlns attribute pointing to my XSD file's namespace being present in the custom config element. However, when running the project I get an Unrecognized attribute 'xmlns'. Note that attribute names are case-sensitive error. I could probably just modify my XSD file to define the xmlns attribute for that element, however I am wondering if this is just a bandaid fix to a larger problem. I must confess I don't have a very good understanding of XML namespaces so this might be an oppportunity to set me straight on a few things. Here is the attributes for my XSD file's root xs:schema element: <xs:schema id="awesomeConfig" targetNamespace="http://awesome.com/schemas" xmlns="http://awesome.com/schemas" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> ... </xs:schema> And on creating the element in the Web.config file, Visual Studio 2008 automatically appends: <awesomeConfig xmlns="http://awesome.com/schemas"></awesomeConfig> So have I misunderstood the meaning of the xs:schema attributes at all, or is the proper solution as simple as it seems?

    Read the article

  • Java OO design confusion: how to handle actions modified by states modified by actions...

    - by Arvanem
    Hi folks, Given an entity, whose action is potentially modified by states (of the entity and other entities) in turn potentially modified by other actions (of the entity and other entities) , what is the best way to code or design to handle the potential existence of the modifiers? Speaking metaphorically, I am coding a Java application representing a piano. As you know a piano has keys (which, when pressed, emit sound) and pedals (which, when pressed, modify the keys' sounds). My base class structure is as follows: Entity (for keys and pedals) State (this holds each entity's states, e.g. name such as "soft pedal", and boolean "Pressed"), Action (this holds each entity's actions, e.g. play sound when pressed, or modify others sounds). By composition, the Entity class has a copy of each of State and Action inside it. e.g.: public class Entity { State entityState = new State(); Action entityAction = new Action(); Thus I have coded a "C-Sharp" key Entity. When I "press" that entity (set its "Pressed" state to true), its action plays a "C-Sharp" sound and then sets its "Pressed" state to false. At the same time, if the "C-Sharp" key entity is not "tuned", its sound deviates from "C-Sharp". Meanwhile I have coded a "soft pedal" Entity. When that entity is "pressed", no sound plays but its action is to make softer the sound of the "C-Sharp" and other key entities. I have also coded a "sustain pedal" Entity. When that entity is "pressed", no sound plays but its action is to enable reverberation of the sound of the "C-Sharp" and other key entities. Both the "soft" and "sustain pedals" can be pressed at the same time with the result that keys entities become both softened and reverberating. In short, I do not understand how to make this simultaneous series of states and actions modify each other in a sensible OO way. I am wary of coding a massive series of "if" statements or "switches". Thanks in advance for any help or links you can offer.

    Read the article

  • Implementing IXmlSerializable on a generated class that has XmlTypeAttribute

    - by Josh
    Basically, the initial problem is I need to make a boolean value serialize as 0 or 1. The solution I found was to implement IXmlSerializable, which I did. Unfortunately the class I'm trying to serialize is generated code off a schema and has an XmlTypeAttribute on it. When I try to (de)serialize the object with the XmlSerializer created in the usual manner ( new XmlSerializer(type)) it throws this exception: System.InvalidOperationException: Only XmlRoot attribute may be specified for the type ______ Please use XmlSchemaProviderAttribute to specify schema type. Two options come to mind immediatly: 1) remove the attribute in the generated code. This change would have to be made every time the code was re-generated. 2) Use an XmlAttributeOverrides object when creating the serializer to remove the attribute. This would require the rest of the code base to "know" that it needs to override that attribute. Also, the exception thrown gives absolutly no clue as to what needs to be done to fix it. Both options kinda stink. Is there a third option?

    Read the article

  • get value from css using document.getElementById().style.height javascript

    - by Jamex
    Hi, Please offer insight into this mystery. I am trying to get the height value from a div box by var high = document.getElementById("hintdiv").style.height; alert(high); I can get this value just fine if the attribute is contained within the div tag, but it returns a blank value if the attribute is defined in the css section. This is fine, it shows 100px as a value. The value can be accessed. <div id="hintdiv" style="height:100px; display: none;"> . . var high = document.getElementById("hintdiv").style.height; alert(high); This is not fine, it shows an empty alert screen. The value is practically 0. #hintdiv { height:100px display: none; } <div id="hintdiv"> . . var high = document.getElementById("hintdiv").style.height; alert(high); But I have no problem accessing/changing the "display:none" attribute whether it is in the tag or in the css section. The div box displays correctly by both attribute definition methods (inside the tag or in the css section). I also tried to access the value by other variations, but no luck document.getElementById("hintdiv").style.height.value ----> undefined document.getElementById("hintdiv").height ---->undefined document.getElementById("hintdiv").height.value ----> error, no execution Any solution? TIA.

    Read the article

  • XNA Vector2 Rotation Question

    - by Tom Allen
    I'm messing about with some stuff in XNA and am trying to move an object around asteroids-style in that you press left and right to rotate and up/down to go forwards and backwards in the direction you are pointing. I've got the rotation of the sprite done, but i can't get the object to move in the direction you've pointed it, it always moves up and down on the x = 0 axis. I'm guessing this is straight forward but I just can't figure it out. My "ship" class has the following properties which are note worthy here: Vector2 Position float Rotation The "ship" class has an update method is where the input is handled and so far I've got the following: public void Update(GameTime gameTime) { KeyboardState keyboard = Keyboard.GetState(); GamePadState gamePad = GamePad.GetState(PlayerIndex.One); float x = Position.X; float y = Position.Y; if (keyboard.IsKeyDown(Keys.Left)) Rotation -= 0.1f; if (keyboard.IsKeyDown(Keys.Right)) Rotation += 0.1f; if (keyboard.IsKeyDown(Keys.Up)) y -= ??; if (keyboard.IsKeyDown(Keys.Down)) y += ??; this.Position = new Vector2(x, y); } Any help would be most appreciated!

    Read the article

  • GAE Simple Request Handler only run once

    - by Hiro
    Good day! https://developers.google.com/appengine/docs/python/gettingstarted/helloworld this is the hello world that I'm trying to run. I can seeing the Hello, world! Status: 500 message. however it will be turned to a "HTTP Error 500" after I hit the refresh. and... it seems that the appengine only shows me the good result once after I re-save either app.yaml or helloworld.py This is the trace for the good result Traceback (most recent call last): File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in _LoadHandler raise ImportError('%s has no attribute %s' % (handler, name)) ImportError: <module 'helloworld' from 'D:\work\[GAE] tests\helloworld\helloworld.pyc'> has no attribute app INFO 2012-06-23 01:47:28,522 dev_appserver.py:2891] "GET /hello HTTP/1.1" 200 - ERROR 2012-06-23 01:47:30,040 wsgi.py:189] and this is the trace for the Error 500 Traceback (most recent call last): File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in _LoadHandler raise ImportError('%s has no attribute %s' % (handler, name)) ImportError: <module 'helloworld' from 'D:\work\[GAE] tests\helloworld\helloworld.pyc'> has no attribute app INFO 2012-06-23 01:47:30,127 dev_appserver.py:2891] "GET /hello HTTP/1.1" 500 - here's my helloworld.py print 'Content-Type: text/plain' print '' print 'Hello, world!' my main.py. (app is used instead of application) import webapp2 class hello(webapp2.RequestHandler): def get(self): self.response.out.write('normal hello') app = webapp2.WSGIApplication([ ('/', hello), ], debug = True) and the app.yaml application: helloworld version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: - url: /favicon\.ico static_files: favicon.ico upload: favicon\.ico - url: /hello script: helloworld.app - url: /.* script: main.app libraries: - name: webapp2 version: "2.5.1" any clue what's causing this? Regards,

    Read the article

  • Android XmlSerializer limitation?

    - by Rexb
    Hi all, My task is just to get an xml string using XmlSerializer. Problem is that it seems like the serializer stops adding any new element and/or attribute to the xml document when it reaches certain length (perhaps 10,000 char?). My questions: have you experience this kind of problem? What could be possible solutions? Here is my sample test code: public void doSerialize() throws XmlPullParserException, IllegalArgumentException, IllegalStateException, IOException { StringWriter writer = new StringWriter(); XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer(); serializer.setOutput(writer); serializer.startDocument(null, null); serializer.startTag(null, "START"); for (int i = 0; i < 20; i++) { serializer.attribute(null, "ATTR" + i, "VAL " + i); } serializer.startTag(null, "DATA"); for (int i = 0; i < 500; i++) { serializer.attribute(null, "attr" + i, "value " + i); } serializer.endTag(null, "DATA"); serializer.endTag(null, "START"); serializer.endDocument(); String xml = writer.toString(); // value: until 493rd attribute int n = xml.length(); // value: 10125 } Any help will be greatly appreciated.

    Read the article

  • Accepting more simultaneous keyboard inputs

    - by unknownthreat
    Sometimes, a normal computer keyboard will only accept user's inputs up to a certain key simultaneously. I got a logitech keyboard that can accept up to 3-4 key presses at the same time. The computer does not accept any more input if you press more than 4 keys for this keyboard. And it also depends on certain areas of your keyboard as well. Some locations allow more key to be pressed (like the arrow keys), while some locations permit you to press only 1-2 keys. This also differs from keyboard to keyboard as well. Some older keyboards only accept up 1-2 keys. This isn't problematic with usual office work, but when it comes to gaming. For instance, imagine a platform game, where you have to jump, attack, and control direction at the same time. This implies several key presses and some keyboards cannot accept such simultaneous input. However, I've tried this on several games and the amount of possible keyboard inputs seem to be also different. Therefore, we have two issues: Keyboards have different amount of simultaneous inputs. Some games can accept more keyboard inputs than other games. At first, I thought this is hardware only problem, but why do some programs behave differently? Why some programs can accept more keyboard inputs than other programs? So how can we write our programs to accept more keyboard inputs?

    Read the article

  • NES Programming - Nametables?

    - by Jeffrey Kern
    Hello everyone, I'm wondering about how the NES displays its graphical muscle. I've researched stuff online and read through it, but I'm wondering about one last thing: Nametables. Basically, from what I've read, each 8x8 block in a NES nametable points to a location in the pattern table, which holds graphic memory. In addition, the nametable also has an attribute table which sets a certain color palette for each 16x16 block. They're linked up together like this: (assuming 16 8x8 blocks) Nametable, with A B C D = pointers to sprite data: ABBB CDCC DDDD DDDD Attribute table, with 1 2 3 = pointers to color palette data, with < referencing value to the left, ^ above, and ' to the left and above: 1<2< ^'^' 3<3< ^'^' So, in the example above, the blocks would be colored as so 1A 1B 2B 2B 1C 1D 2C 2C 3D 3D 3D 3D 3D 3D 3D 3D Now, if I have this on a fixed screen - it works great! Because the NES resolution is 256x240 pixels. Now, how do these tables get adjusted for scrolling? Because Nametable 0 can scroll into Nametable 1, and if you keep scrolling Nametable 0 will wrap around again. That I get. But what I don't get is how to scroll the attribute table wraps around as well. From what I've read online, the 16x16 blocks it assigns attributes for will cause color distortions on the edge tiles of the screen (as seen when you scroll left to right and vice-versa in SMB3). The concern I have is that I understand how to scroll the nametables, but how do you scroll the attribute table? For intsance, if I have a green block on the left side of the screen, moving the screen to right should in theory cause the tiles to the right to be green as well until they move more into frame, to which they'll revert to their normal colors.

    Read the article

  • How do I establish table association in JPA / Hibernate with existing database?

    - by Paperino
    Currently I have two tables in my database Encounters and Referrals: There is a one to many relationship between these two tables. Currently they are linked together with foreign keys. Right now I have public class Encounter extends JPASupport implements java.io.Serializable { @Column(name="referralid", unique=false, nullable=true, insertable=true, updatable=true) public Integer referralid; } But what I really want is public class Encounter extends JPASupport implements java.io.Serializable { .......... @OneToMany(cascade=CascadeType.PERSIST) public Set<Referrals> referral; ............ } So that I can eventually do a query like this: List<Encounter> cases = Encounter.find( "select distinct p from Encounter p join p.referrals as t where t.caseid =103" ).fetch(); How do I tell JPA that even though I have non-standard column names for my foreign keys and primary keys that its the object models that I want linked, not simply the integer value for the keys? Does this make sense? I hope so. Thanks in advanced!

    Read the article

  • EMF ecore and xsd out of sync, how to resolve ?

    - by SeB
    Hi there, My application is using a model base on an xsd that have been converted to an ecore before generation of the java classes. One of my team member modified the .ecore metamodel in a previous version ,one attribute that used to be generated. He modified the attribute name but not the Extended MetaData specifying the element name used for xml persistance. <eStructuralFeatures xsi:type="ecore:EReference" name="javaDocsAndUserApi" upperBound="-1" eType="#//JavaDocsAndUserApi" containment="true" resolveProxies="false"> <eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData"> <details key="kind" value="element"/> <details key="name" value="docsAndUserApi"/> </eAnnotations> </eStructuralFeatures> so we have an attribute name which is javaDocsAndUserApi and the persisted element named docsAndUserApi, and of course if I create change the attribute in the xsd to be named javaDocsAndUserApi, the ecore transformation will generate a metadata name javaDocsAndUserApi as well, which will break compatibility with previously persisted models. I have looked at xsd authoring guide to find an ecore:som_attribute that would allow me to specify which key to use in the xsd to force the metadata to be named docsAndUserApi during the xsd to ecore transformation but did not find anything. Does anybody have an idea to help me? Thank you.

    Read the article

  • Having some fun - what is a good way to include a secret key functionality and fire the KeyDown event?

    - by Sisyphus
    To keep myself interested, I try to put little Easter Eggs in my projects (mostly to amuse myself). I've seen some websites where you can type a series of letters "aswzaswz" and you get a "secret function" - how would I achieve this in C#? I've assigned a "secret function" in the past by using modifier keys bool showFunThing = (Control.ModifierKeys & Keys.Control) == Keys.Control; but wanted to get a bit more secretive (without the modifier keys) I just wanted the form to detect a certain word typed without any input ... I've built a method that I think should do it: private StringBuilder _pressedKeys = new StringBuilder(); protected override void OnKeyDown(KeyEventArgs e) { const string kWord = "fun"; char letter = (char)e.KeyValue; if (!char.IsLetterOrDigit(letter)) { return; } _pressedKeys.Append(letter); if (_pressedKeys.Length == kWord.Length) { if (_pressedKeys.ToString().ToLower() == kWord) { MessageBox.Show("Fun"); _pressedKeys.Clear(); } } base.OnKeyDown(e); } Now I need to wire it up but I can't figure out how I'm supposed to raise the event in the form designer ... I've tried this: this.KeyDown +=new System.Windows.Forms.KeyEventHandler(OnKeyDown); and a couple of variations on this but I'm missing something because it won't fire (or compile). It tells me that the OnKeyDown method is expecting a certain signature but I've got other methods like this where I haven't specified arguments. I fear that I may have got myself confused so I am turning to SO for help ... anyone?

    Read the article

  • Which is better Java programming practice: stacking enums and enum constructors, or subclassing?

    - by Arvanem
    Hi folks, Given a finite number of items which differ in kind, is it better to represent them with stacked enums and enum constructors, or to subclass them? Or is there a better approach altogether? To give you some context, in my small RPG program (which ironically is supposed to be simple), a character has different kinds of items in his or her inventory. Items differ based on their type and use and effect. For example, one item of inventory is a spell scroll called Gremlin that adjusts the Utility attribute. Another item might be a sword called Mort that is used in combat and inflicts damage. In my RPG code, I now have tried two ways of representing inventory items. One way was subclassing (for example, InventoryItem - Spell - AdjustingAttributes; InventoryItem - Weapon - Sword) and instantiating each subclass when needed, and assigning values such as names like Gremlin and Mort. The other way was by stacking enums and enum constructors. For example, I created enums for itemCategory and itemSpellTypes and itemWeaponTypes, and the InventoryItem enum was like this: public enum InventoryItem { GREMLIN(itemType.SPELL, itemSpellTypes.ATTRIBUTE, Attribute.UTILITY), MORT(itemType.WEAPON, itemWeaponTypes.SWORD, 30); InventoryItem(itemType typeOfItem, itemSpellTypes spellType, Attribute attAdjusted) { // snip, enum logic here } InventoryItem(itemType typeOfItem, itemWeaponTypes weaponType, int dmg) { // snip, enum logic here } // and so on, for all the permutations of items. } Is there a better Java programming practice than these two approaches? Or if these are the only ways, which of the two is better? Thanks in advance for your suggestions.

    Read the article

  • How to Get Dictionary<int, string> from Linq to XML Anonymous Object?

    - by DaveDev
    Currently I'm getting a list of HeaderColumns from the following XML snippet: <HeaderColumns> <column performanceId="12" text="Over last month %" /> <column performanceId="13" text="Over last 3 months %" /> <column performanceId="16" text="1 Year %" /> <column performanceId="18" text="3 Years % p.a." /> <column performanceId="20" text="5 Years % p.a." /> <column performanceId="22" text="10 Years % p.a." /> </HeaderColumns> from which I create an object as follows: (admitedly similar to an earlier question!) var performancePanels = new { Panels = (from panel in doc.Elements("PerformancePanel") select new { HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new { PerformanceId = (int)column.Attribute("performanceId"), Text = (string)column.Attribute("text") }).ToList(), }).ToList() }; I'd like if HeaderColumns was a Dictionary() so later I extract the values from the anonymous object like follows: Dictionary<int, string> myHeaders = new Dictionary<int, string>(); foreach (var column in performancePanels.Panels[0].HeaderColumns) { myHeaders.Add(column.PerformanceId, column.Text); } I thought I could achieve this with the Linq to XML with something similar to this HeaderColumns = (from column in panel.Elements("HeaderColumns").Elements("column") select new Dictionary<int, string>() { (int)column.Attribute("performanceId"), (string)column.Attribute("text") }).ToDictionary<int,string>(), but this doesn't work because ToDictionary() needs a Func parameter and I don't know what that is / how to implement it, and the code's probably wrong anyway! Could somebody please suggest how I can achieve the result I need? Thanks.

    Read the article

  • How do you work around memcached's key/value limitations?

    - by mjy
    Memcached has length limitations for keys (250?) and values (roughtly 1MB), as well as some (to my knowledge) not very well defined character restrictions for keys. What is the best way to work around those in your opinion? I use the Perl API Cache::Memcached. What I do currently is store a special string for the main key's value if the original value was too big ("parts:<number") and in that case, I store <number parts with keys named 1+<main key, 2+<main key etc.. This seems "OK" (but messy) for some cases, not so good for others and it has the intrinsic problem that some of the parts might be missing at any time (so space is wasted for keeping the others and time is wasted reading them). As for the key limitations, one could probably implement hashing and store the full key (to work around collisions) in the value, but I haven't needed to do this yet. Has anyone come up with a more elegant way, or even a Perl API that handles arbitrary data sizes (and key values) transparently? Has anyone hacked the memcached server to support arbitrary keys/values?

    Read the article

  • Loading Dimension Tables - Methodologies

    - by Nev_Rahd
    Hello, Recently I been working on project, where need to populated Dim Tables from EDW Tables. EDW Tables are of type II which does maintain historical data. When comes to load Dim Table, for which source may be multiple EDW Tables or would be single table with multi level pivoting (on attributes). Mean: There would be 10 records - one for each attribute which need to be pivoted on domain_code to make a single row in Dim. Out of these 10 records there would be some attributes with same domain_code but with different sub_domain_code, which needs further pivoting on subdomain code. Ex: if i got domain code: 01,02, 03 = which are straight pivot on domain code I would also have domain code: 10 with subdomain code / version as 2006,2007,2008,2009 That means I need to split my source table with above attributes into two = one for domain code and other for domain_code + version. so far so good. When it comes to load Dim Table: As per design specs for Dimensions (originally written by third party), what they want is: for every single change in EDW (attribute), it should assemble all the related records (for that NK) mean new one with other attribute values which are current = process them to create a new dim record and insert it. That mean if a single extract contains 100 records updated (one for each NK), it should assemble 100 + (100*9) records to insert / update dim table. How good is this approach. Other way I tried to do is just do a lookup into dim table for that NK get the value's of recent records (attributes which not changed) and insert it and update the current one. What would be the better approach assembling records at source side for one attribute change or looking into dim table's recent record and process it. If this doesn't make sense, would like to elaborate it further. Thanks

    Read the article

  • Update/Insert without select

    - by user348731
    I have this very simple class public class ProductAttributeValuePortal { public virtual int ID { get; set; } public virtual Domain.Entity.Portals.ProductPortal Product { get; set; } public virtual Attribute Attribute { get; set; } public virtual string Value { get; set; } } with this very simple map public ProductAttributeValueMap () { Table("DM.dbo.ProductAttributeValues"); Id(x => x.ID, "ProductAttributeValue_id"); References(x => x.Product); References(x => x.Attribute); Map(x => x.Value); } Each time i make a insert NHibernate makes a Select of the attribute like : NHibernate: INSERT INTO MachineData.dbo.ProductAttributeValues (Value, Product_id, Attribute_id) VALUES (@p0, @p1, @p2); select SCOPE_IDENTITY();@p0 = '6745', @p1 = 39, @p2 = 'BSTD' NHibernate: SELECT attribute_.Attribute_id, attribute_.Name as Name21_, attribute_.AttributeType as Attribut3_21_, attribute_.TagName as TagName21_, attribute_.MapTo as MapTo21_ FROM MachineShared.dbo.Attributes attribute_ WHERE attribute_.Attribute_id=@p0;@p0 = 'DLB' What am i doing wrong. And where do i find some really uptodate books about nhibernate/Fluent nhibernate

    Read the article

  • Optimization of Function with Dictionary and Zip()

    - by eWizardII
    Hello, I have the following function: def filetxt(): word_freq = {} lvl1 = [] lvl2 = [] total_t = 0 users = 0 text = [] for l in range(0,500): # Open File if os.path.exists("C:/Twitter/json/user_" + str(l) + ".json") == True: with open("C:/Twitter/json/user_" + str(l) + ".json", "r") as f: text_f = json.load(f) users = users + 1 for i in range(len(text_f)): text.append(text_f[str(i)]['text']) total_t = total_t + 1 else: pass # Filter occ = 0 import string for i in range(len(text)): s = text[i] # Sample string a = re.findall(r'(RT)',s) b = re.findall(r'(@)',s) occ = len(a) + len(b) + occ s = s.encode('utf-8') out = s.translate(string.maketrans("",""), string.punctuation) # Create Wordlist/Dictionary word_list = text[i].lower().split(None) for word in word_list: word_freq[word] = word_freq.get(word, 0) + 1 keys = word_freq.keys() numbo = range(1,len(keys)+1) WList = ', '.join(keys) NList = str(numbo).strip('[]') WList = WList.split(", ") NList = NList.split(", ") W2N = dict(zip(WList, NList)) for k in range (0,len(word_list)): word_list[k] = W2N[word_list[k]] for i in range (0,len(word_list)-1): lvl1.append(word_list[i]) lvl2.append(word_list[i+1]) I have used the profiler to find that it seems the greatest CPU time is spent on the zip() function and the join and split parts of the code, I'm looking to see if there is any way I have overlooked that I could potentially clean up the code to make it more optimized, since the greatest lag seems to be in how I am working with the dictionaries and the zip() function. Any help would be appreciated thanks!

    Read the article

  • Recursive Enumeration in Java

    - by Harm De Weirdt
    Hello everyone. I still have a question about Enumerations. Here's a quick sketch of the situation. I have a class Backpack that has a Hashmap content with as keys a variable of type long, and as value an ArrayList with Items. I have to write an Enumeration that iterates over the content of a Backpack. But here's the catch: in a Backpack, there can also be another Backpack. And the Enumeration should also be able to iterate over the content of a backpack that is in the backpack. (I hope you can follow, I'm not really good at explaining..) Here is the code I have: public Enumeration<Object> getEnumeration() { return new Enumeration<Object>() { private int itemsDone = 0; //I make a new array with all the values of the HashMap, so I can use //them in nextElement() Collection<Long> keysCollection = getContent().keySet(); Long [] keys = keysCollection.toArray(new Long[keysCollection.size()]); public boolean hasMoreElements() { if(itemsDone < getContent().size()) { return true; }else { return false; } } public Object nextElement() { ArrayList<Item> temporaryList= getContent().get(keys[itemsDone]); for(int i = 0; i < temporaryList.size(); i++) { if(temporaryList.get(i) instanceof Backpack) { return temporaryList.get(i).getEnumeration(); }else { return getContent().get(keys[itemsDone++]); } } } }; Will this code work decently? It's just the "return temporaryList.get(i).getEnumeration();" I'm worried about. Will the users still be able to use just the hasMoreElemens() and nextElement() like he would normally do? Any help is appreciated, Harm De Weirdt

    Read the article

  • JSTL <c:out> where the element name contains a space character...

    - by Shane
    I have an array of values being made available, but unfortunately some of the variable names include a space. I cannot work out how to simply output these in the page. I know I'm not explaining this well (I'm the JSP designer, not the Java coder) so hopefully this example will illustrate what I'm trying to do: <c:out value="${x}"/> outputs to the page (artificially wrapped) as: {width=96.0, orderedheight=160.0, instructions=TEST ONLY. This is a test., productId=10132, publication type=ns, name=John} I can output the name by using <c:out value="${x.name}"/> no problems. The issue is when I try to get the "publication type"... because it has a space, I can't seem to get <c:out> to display it. I have tried: <!-- error parsing custom action attribute: --> <c:out value="${x.publication type}"/> <!-- error occurred while evaluating custom action attribute: --> <c:out value="${x.publication+type}"/> <!-- error occurred while parsing custom action attribute: --> <c:out value="${x.'publication type'}"/> <!-- error occurred while parsing custom action attribute: --> <c:out value="${x.publication%20type}"/> I know the real solution is to get the variable names formatted correctly (ie: without spaces) but I can't get the code updated for quite a while. Can this be done? Any help greatly appreciated.

    Read the article

  • How do you unit-test a method with complex input-output

    - by Dan
    When you have a simple method, like for example sum(int x, int y), it is easy to write unit tests. You can check that method will sum correctly two sample integers, for example 2 + 3 should return 5, then you will check the same for some "extraordinary" numbers, for example negative values and zero. Each of these should be separate unit test, as a single unit test should contain single assert. What do you do when you have a complex input-output? Take a Xml parser for example. You can have a single method parse(String xml) that receives the String and returns a Dom object. You can write separate tests that will check that certain text node is parsed correctly, that attributes are parsed OK, that child node belongs to parent etc. For all these I can write a simple input, for example <root><child/></root> that will be used to check parent-child relationships between nodes and so on for the rest of expectations. Now, take a look at follwing Xml: <root> <child1 attribute11="attribute 11 value" attribute12="attribute 12 value">Text 1</child1> <child2 attribute21="attribute 21 value" attribute22="attribute 22 value">Text 2</child2> </root> In order to check that method worked correctly, I need to check many complex conditions, like that attribute11 and attribute12 belong to element1, that Text 1 belongs to child1 etc. I do not want to put more than one assert in my unit-test. How can I accomplish that?

    Read the article

  • [c++] - Help about class and error: C3861

    - by Chelsea_cole
    Can someone help me in this error? in "cDef.h" : #pragma once class cDef { public: static int STATE_LOGO; static int STATE_MENU; static int MESSAGE_ENTER; static int MESSAGE_UPDATE; static int MESSAGE_PAINT; static int MESSAGE_EXIT; }; in "GameState.h": #pragma once #ifndef _GameState_ #define _GameState_ #include "cDef.h" class MainGame; class GameState; class GameState { public: MainGame *mg; int GAME_STATE_DEF; virtual void MessengeEnter(int message) = 0; virtual void MessengeUpdate(int message,int keys) = 0; virtual void MessengePaint(int message,CDC *pDc) = 0; void StateHandler(int message,CDC *pDc,int keys); public: GameState(void); public: ~GameState(void); }; #endif in "GameState.cpp": #include "StdAfx.h" #include "GameState.h" GameState::GameState(void) { GAME_STATE_DEF = -1; } GameState::~GameState(void) { } void GameState::StateHandler(int message,CDC *pDc,int keys) { if(message == cDef.MESSAGE_ENTER) { MessageEnter(message); } if(message == cDef.MESSAGE_UPDATE) { MessageUpdate(message,keys); } if(message == cDef.MESSAGE_PAINT) { MessagePaint(message,pDC); } } error: warning C4832: token '.' is illegal after UDT 'cDef' see declaration of 'cDef' error C3861: 'MessageUpdate': identifier not found error C3861: 'MessageEnter': identifier not found error C3861: 'MessagePaint': identifier not found ..... Thanks in advance!

    Read the article

< Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >