Search Results

Search found 6420 results on 257 pages for 'mathieu parent'.

Page 36/257 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • Mutiple FK columns all pointing to the same parent table - a good idea?

    - by Randy Minder
    For those of you who live and breath database design, have you ever found compelling reasons to have multiple FK's in a table that all point to the same parent table? We recently had to deal with a situation where we had a table that contained six columns which were all FK columns to the same parent table. We're debating whether this indicates a poor design on our part or whether this is more common than we think. Thanks very much.

    Read the article

  • How to make new file permission inherit from the parent directory?

    - by Wai Yip Tung
    I have a directory called data. Then I am running a script under the user id 'robot'. robot writes to the data directory and update files inside. The idea is data is open for both me and robot to update. So I setup the permission and owner group like this drwxrwxr-x 2 me robot-grp 4096 Jun 11 20:50 data where both me and robot belongs to the 'robot-grp'. I change the permission and the owner group recursively like the parent directory. I regularly upload new files into the data directory using rsync. Unfortunately, new files uploaded does not inherit the parent directory's permission as I hope. Instead it looks like this -rw-r--r-- 1 me users 6 Jun 11 20:50 new-file.txt When robot tries to update new-file.txt, it fails due to lack of file permission. I'm not sure if setting umask helps. In anycase the new files does not really follow it. $ umask -S u=rwx,g=rx,o=rx I'm often confounded by Unix file permission. Do I even have a right plan? I'm using Debian lenny.

    Read the article

  • How to make new file permission inherit from the parent directory?

    - by Wai Yip Tung
    I have a directory called data. Then I am running a script under the user id 'robot'. robot writes to the data directory and update files inside. The idea is data is open for both me and robot to update. So I setup the permission and owner group like this drwxrwxr-x 2 me robot-grp 4096 Jun 11 20:50 data where both me and robot belongs to the 'robot-grp'. I change the permission and the owner group recursively like the parent directory. I regularly upload new files into the data directory using rsync. Unfortunately, new files uploaded does not inherit the parent directory's permission as I hope. Instead it looks like this -rw-r--r-- 1 me users 6 Jun 11 20:50 new-file.txt When robot tries to update new-file.txt, it fails due to lack of file permission. I'm not sure if setting umask helps. In anycase the new files does not really follow it. $ umask -S u=rwx,g=rx,o=rx I'm often confounded by Unix file permission. Do I even have a right plan? I'm using Debian lenny.

    Read the article

  • Maven : Is it possible to override the configuration of a plugin already defined for a profile in a parent POM

    - by Guillaume Cernier
    In a POM parent file of my project, I have such a profile defining some configurations useful for this project (so that I can't get rid of this parent POM) : <profile> <id>wls7</id> ... <build> <plugins> <!-- use java 1.4 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <fork>true</fork> <source>1.4</source> <target>1.4</target> <meminitial>128m</meminitial> <maxmem>1024m</maxmem> <executable>%${jdk14.executable}</executable> </configuration> </plugin> </plugins> </build> ... </profile> But in my project I just would like to override the configuration of the maven-compiler-plugin in order to use jdk5 instead of jdk4 for compiling test-classes. That's why I did this section in the POM of my project : <profiles> <profile> <id>wls7</id> <activation> <property> <name>jdk</name> <value>4</value> </property> </activation> <build> <directory>target-1.4</directory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <executions> <execution> <id>my-testCompile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> <configuration> <fork>true</fork> <executable>${jdk15.executable}</executable> <compilerVersion>1.5</compilerVersion> <source>1.5</source> <target>1.5</target> <verbose>true</verbose> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile> ... </profiles> and it's not working ... I even tried to override the configuration in regular plugin sections of my POM (I mean, not for a specific profile but for my whole POM). What could be the problem ? To clarify some of my requirements : I don't want to get rid of the parent POM and the profile (wls7) defined inside it (since I need many and many properties, configurations, ...) and that is not the process in my company. A solution based on duplicating the parent POM and/or the profile defined inside it is not a good one. Since if the responsible of the parent POM change something, I would have to report it in mine. It's just an inheritance matter (extend or override a profile, a configuration from an upper-level POM) so I think it should be possible with maven2.

    Read the article

  • Working with EO composition associations via ADF BC SDO web services

    - by Chris Muir
    ADF Business Components support the ability to publish the underlying Application Modules (AMs) and View Objects (VOs) as web services through Service Data Objects (SDOs).  This blog post looks at a minor challenge to overcome when using SDOs and Entity Objects (EOs) that use a composition association. Using the default ADF BC EO association behaviour ADF BC components allow you to work with VOs that are based on EOs that are a part of a parent-child composition association.  A composition association enforces that you cannot create records for the child outside the context of the parent.  As example when creating invoice-lines you want to enforce the individual lines have a relating parent invoice record, it just simply doesn't make sense to save invoice-lines without their parent invoice record. In the following screenshot using the ADF BC Tester it demonstrates the correct way to create a child Employees record as part of a composition association with Departments: And the following screenshot shows you the wrong way to create an Employee record: Note the error which is enforced by the composition association: (oracle.jbo.InvalidOwnerException) JBO-25030: Detail entity Employees with row key null cannot find or invalidate its owning entity.  Working with composition associations via the SDO web services  Shay Shmeltzer recently recorded a good video which demonstrates how to expose your ADF Business Components through the SDO interface. On exposing the VOs you get a choice of operation to publish including create, update, delete and more: For example through the SDO test interface we can see that the create operation will request the attributes for the VO exposed, in this case EmployeesView1: In this specific case though, just like the ADF BC Tester, an attempt to create this record will fail with JBO-25030, the composition association is still enforced: The correct way to to do this is through the create operation on the DepartmentsView1 which also lets you create employees record in context of the parent, thus satisfying the composition association rule: Yet at issue here is the create operation will always create both the parent Departments and Employees records.  What do we do if we've already previously created the parent Departments records, and we just want to create additional Employees records for that Department?  The create method of the EmployeeView1 as we saw previously doesn't allow us to do that, the JBO-3050 error will be raised. The solution is the "merge" operation on the parent Departments record: In this case for the Departments record you just need to supply the DepartmentId of the Department you want the Employees record to be associated with, as well as the new Employees record.  When invoked only the Employees record is created, and the supply of the DepartmentId of the Departments record satisfies the composition association without actually creating or updating the associated Department record that already exists in the database. Be warned however if you supply any more attributes for the Department record, it will result in a merge (update) of the associated Departments record too. 

    Read the article

  • Change alpha to a Frame in libgdx

    - by Rudy_TM
    I have this batch.draw(currentFrame, x, y, this.parent.originX, this.parent.originY, this.parent.width, this.parent.height, this.scaleX, this.scaleY,this.rotation); I want to apply the alpha that it gets from the method, but theres is not overload from the SpriteBatch class that takes the alpha value, is there some wey to apply it? (i did it this way, because this are animation, and i wanted to control them) in my static ones i apply sprite.draw(SpriteBatch, alpha) Thanks

    Read the article

  • Enum types, FlagAttribute & Zero value

    - by nmgomes
    We all know about Enums types and use them every single day. What is not that often used is to decorate the Enum type with the FlagsAttribute. When an Enum type has the FlagsAttribute we can assign multiple values to it and thus combine multiple information into a single enum. The enum values should be a power of two so that a bit set is achieved. Here is a typical Enum type: public enum OperationMode { /// <summary> /// No operation mode /// </summary> None = 0, /// <summary> /// Standard operation mode /// </summary> Standard = 1, /// <summary> /// Accept bubble requests mode /// </summary> Parent = 2 } In such scenario no values combination are possible. In the following scenario a default operation mode exists and combination is used: [Flags] public enum OperationMode { /// <summary> /// Asynchronous operation mode /// </summary> Async = 0, /// <summary> /// Synchronous operation mode /// </summary> Sync = 1, /// <summary> /// Accept bubble requests mode /// </summary> Parent = 2 } Now, it’s possible to do statements like: [DefaultValue(OperationMode.Async)] [TypeConverter(typeof(EnumConverter))] public OperationMode Mode { get; set; } /// <summary> /// Gets a value indicating whether this instance supports request from childrens. /// </summary> public bool IsParent { get { return (this.Mode & OperationMode.Parent) == OperationMode.Parent; } } or switch (this.Mode) { case OperationMode.Sync | OperationMode.Parent: Console.WriteLine("Sync,Parent"); break;[…]  But there is something that you should never forget: Zero is the absorber element for the bitwise AND operation. So, checking for OperationMode.Async (the Zero value) mode just like the OperationMode.Parent mode makes no sense since it will always be true: (this.Mode & 0x0) == 0x0 Instead, inverse logic should be used: OperationMode.Async = !OperationMode.Sync public bool IsAsync { get { return (this.Mode & ContentManagerOperationMode.Sync) != ContentManagerOperationMode.Sync; } } or public bool IsAsync { get { return (int)this.Mode == 0; } } Final Note: Benefits Allow multiple values combination The above samples snippets were taken from an ASP.NET control and enabled the following markup usage: <my:Control runat="server" Mode="Sync,Parent"> Drawback Zero value is the absorber element for the bitwise AND operation Be very carefully when evaluating the Zero value, either evaluate the enum value as an integer or use inverse logic.

    Read the article

  • How to secure Add child record functionality in MVC on Parent's view?

    - by RSolberg
    I'm trying to avoid some potential security issues as I expose some a new set of functionality into the real world. This is basically functionality that will allow for a new comment to be added via a partialview on the "Parent" page. My comment needs to know a couple of things, first what record is the comment for and secondly who is making the comment. I really don't like using a hidden field to store the ID for the Parent record in the add comment form as that can be easily changed with some DOM mods. How should I handle this? PARENT <% Html.RenderPartial("AddComment", Model.Comments); %> CHILD <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CommentsViewModel>" %> <% using (Html.BeginForm("AddComment", "Requests")) {%> <fieldset> <legend>New Comment</legend> <%= Html.HiddenFor(p => p.RequestID) %> <%= Html.TextBoxFor(p => p.Text) %> &nbsp; <input type="submit" value="Add" /> </fieldset> <% } %> CONTROLLER [AcceptVerbs(HttpVerbs.Post)] public void AddComment(CommentsViewModel commentsModel) { var user = GetCurrentUser(); commentsModel.CreatedByID = user.UserID; RequestsService.AddComment(commentsModel); }

    Read the article

  • How do I underline parent menu item but not children?

    - by Steven
    Using Wordpress menu "builder", I get the following code: //Pseaudo code <ul id="main-menu-main"> <li class="menu-item"><a></a></li> <li class="menu-item current-menu-ancestor"> <a></a> <ul class="sub-menu"> <li class="menu-item"><a></a></li> <li class="menu-item current-menu-item"><a></a></li> </ul> </li> </ul> // and I use the following CSS #menu-main-menu a:hover { text-decoration: underline; } #menu-main-menu .current-menu-ancestor a { text-decoration: underline; } The problem with my last css line, is that all a elements under current-menu-ancestor are underlined. I only want the link in current-menu-ancestor to be underlined. I think this should be pretty simple, but right now my head is not focused :-/ The full code for parent / child looks like this: <ul id="menu-main-menu" class="menu"> <li id="menu-item-401" class="menu-item-first menu-item menu-item-type-post_type menu-item-object-page current-page-ancestor current-menu-ancestor current-menu-parent current-page-parent current_page_parent current_page_ancestor menu-item-401"> <a>menu 1</a> <ul class="sub-menu"> <li id="menu-item-444" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-415 current_page_item menu-item-444"> <a> sub 1</a> </li> </ul> </li>

    Read the article

  • jquery for each function

    - by jonathan p
    I have added a show more or less function to a div - this all works fine however now i need to only allow this functionality if a element is over a certain height in this case. there are numerous classes of the same so i need to do the check on each element. although i am having problems getting it to work see code below : $(document).ready(function() { $(".less").hide(); $(".more").each(function() { var actualHeight = ($(this).parent().parent().find('.appsList').height()); if (actualHeight < 150) { $(".more").hide(); } }); $(".more").click(function() { var paragraphHeight = ($(this).parent().parent().find('.appsList').height()); if (paragraphHeight > 150) { $(this).parent().parent().find('.appsHolderBody').animate({height:(paragraphHeight + 100) }); $(this).hide('slow'); $(this).parent().find('.less').show(); } return false; }); $(".less").click(function() { $(this).parent().parent().find('.appsHolderBody').animate({height:190 }); $(this).hide('slow'); $(this).parent().find('.more').show(); return false; }); }); Any help would be greatly appreciated - please note when i am targeting the parent using .parent.parent i know its not pretty but could'nt get it to run using eq(4) for some reason. so the main problem is with this part of code $(".more").each(function() { var actualHeight = ($(this).parent().parent().find('.appsList').height()); if (actualHeight < 150) { $(".more").hide(); } it hides all of the elements $(".more") instead of the ones that match the condition. html as requested <div class="appsHolder"> <div class="appsHolderBody"> <h5 class="appTitle">General Apps</h5> <ul class="appsList"> <li class="mainAppList">Resource Manager</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Resource Manager</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> <li class="mainAppList">Yet Another App</li> <li><a href="">Launch</a> <a href="">Info</a></li> </ul> </div> <div class="appsHolderExpander"> <a href="" class="more">More <img src="/wps/PA_applicationsintros/./img/downArrow.png" /></a> <a href="" class="less">Less <img src="/wps/PA_applicationsintros/./img/upArrow.png" /></a> </div> </div> <div class="appsHolderAdvertising"> <div class="appsHolderBody"> <h5 class="appTitle">Advertising Apps</h5> <ul class="appsList"> <li class="mainAppList">ATEX</li> <li><a href="">Launch</a> <a href="">Info</a></li> </ul> </div> <div class="appsHolderExpander"> <a href="" class="more">More <img src="/wps/PA_applicationsintros/./img/downArrow.png" /></a> <a href="" class="less">Less <img src="/wps/PA_applicationsintros/./img/upArrow.png" /></a> </div> </div> cheers in advance

    Read the article

  • Need a script/batch/program that runs a command that won't be killed when the parent is killed

    - by billc.cn
    The scenario I use Zabbix to monitor my servers and recently I wanted to add some more metrics for the Windows ones. For security reasons, I used Zabbix's User Parameter feature, but it limits the execution of external commands to about 3 seconds. After that, the command is forcibly killed. I want to run some long run commands, so I used the trick from Zabbix's forum: run the command in the background, write the results to a file and use Zabbix to collect them. This is rather easy under *nix thanks to the "&" operator, but there is no such support in Windows' shell. To make things worse, when Zabbix kills forcibly kill the cmd.exe it used to evaluate the commands, all child processes die including the unfinished background tasks. Thus I need something that can sever all the ties with its children so they won't be affected in the cascading kill. What I've tried start and start /B - They do nothing as the child always die with the parent WScript.Shell.Run as in invis.vbs from StackOverflow - Sometimes work. If the wscript process is forcibly killed as opposed to quitting on its own, the children will die as well. hstart - similar results to invis.vbs At command - This requires you to set an absolution time for the task to run as opposed to an offset, so the code would be quite messy due to the limited shell scripting capability of Windows. (Edit) PsExec.exe from the SysInternals suite - It uses a service to launch the command, so it is not affected by the kill; however, it prints some banner and log info to StdErr and there's no switch to disable this. When I use 2>NUL to redirect them, Zabbix reports an error. After trying the above in different combinations, I noticed if I call hstart from invis.vbs, the command started by the former will be left alone as a parent-less process when invis.vbs is killed. However, since I need to redirect the output, the command I want to run is always in the form of cmd.exe /c ""command" "args"" >log. The vbs also removes all the quotes, so I have to encode the command with self-defined escape sequences. The end result involves about five levels of escaping/quoting, which is almost impossible to maintain. Anyone know any better solutions? Some requirements Any bat/vbs/js/Win32 binary is acceptable Better not require multiple levels of escaping No .Net (including PowerShell) because it is not installed

    Read the article

  • How to get a Read-Write Reference to Parent GameObject from a script component attached to it?

    - by onguarde
    I have a game object(object) with a script component(myscript) attached. I have a reference to myscript component through getComponent, and I want to change the transform of the gameObject the script is attached to. myscript.gameObject.transform = (new value); The above code gives me error, Property 'UnityEngine.GameObject.transform' is read only. Is there a way to get a read-write version?

    Read the article

  • Trying to implement pre/post method code: better to use methods or a parent class?

    - by Will
    I'm finding it difficult to frame this question so ... I want to execute code both before and after a method runs in PHP. There are, as far as I know, two ways to implement this: Method One: pre and post methods class Model { function find($id) { $this->_precode(); // ... do stuff $this->post_code(); } } Add the calls to _precode() and _postcode() to each method where I need this functionality. Method Two: __call and method naming class Model extends PrePost { function prepost_find($id) { // ... do stuff ... } } class PrePost { function __call($method,$param) { $method = "prepost_$method"; // .. precode here .. $result = $this->$method($param); // .. postcode here .. } } This relies on naming a method in a specific way in the inheriting class. Is there a preferred way of doing this? The call method can be made to only handle its specific cases and even defer to a child class's call if there is one. I'm not looking for opinions; I'm looking to find out if there are valid reasons to choose one way over another.

    Read the article

  • One-to-one Mapping issue with NHibernate/Fluent: Foreign Key not updateing

    - by Trevor
    Summary: Parent and Child class. One to one relationship between the Parent and Child. Parent has a FK property which references the primary key of the Child. Code as follows: public class NHTestParent { public virtual Guid NHTestParentId { get; set; } public virtual Guid ChildId { get { return ChildRef.NHTestChildId; } set { } } public virtual string ParentName { get; set; } protected NHTestChild _childRef; public virtual NHTestChild ChildRef { get { if (_childRef == null) _childRef = new NHTestChild(); return _childRef; } set { _childRef = value; } } } public class NHTestChild { public virtual Guid NHTestChildId { get; set; } public virtual string ChildName { get; set; } } With the following Fluent mappings: Parent Mapping Id(x => x.NHTestParentId); Map(x => x.ParentName); Map(x => x.ChildId); References(x => x.ChildRef, "ChildId").Cascade.All(); Child Mapping: Id(x => x.NHTestChildId); Map(x => x.ChildName); If I do something like (pseudo code) ... HTestParent parent = new NHTestParent(); parent.ParentName = "Parent 1"; parent.ChildRef.ChildName = "Child 1"; nhibernateSession.SaveOrUpdate(aParent); Commit; ... I get an error: "Invalid index 3 for this SqlParameterCollection with Count=3" If I change the parent 'References' line as follows (i.e. provide the name of the child property I'm pointing at): References(x => x.ChildRef, "ChildId").PropertyRef("NHTestChildId").Cascade.All(); I get the error: "Unable to resolve property: NHTestChildId" So, I tried the 'HasOne()' reference setting, as follows: HasOne<NHTestChild>(x => x.ChildRef).ForeignKey("ChildId").Cascade.All().Fetch.Join(); This results in the save working, but the load fails to find the child. If I inspect the SQL Nhibernate produces I can see that NHibernate is assuming the Primary key of the parent is the link to the child (i.e. load join condition is "parent.NHTestParentId = child.NHTestChildId). The 'ForeignKey' specified appears to be ignored. I can set any value and no error occurs - the join just always fails and no child is returned. I've tried a number of slight variations on the above. It seems like it should be a simple thing to achieve. Any ideas?

    Read the article

  • pyQt4: QWidget subclass not responding to new setStyleSheet() background colour

    - by Ronny
    I am having an issue with PyQt4. I want to create a new widget within a window, and I want this widget to have a custom color. When i create a subclass of the QWidget class, and instantiate it, I am not able to change its background color through the setStyleSheet() function. When I instantiate a new QWidget object, I have no problems in changing its background color. But i dont want an ordinary QWidget object.I want to create my own subclass of QWidget. When i create a subclass of a QPushButton, I am also able to change its background color using the setStyleSheet() function. There are no error messages or warnings in the console window, it just refuses to work properly without any indication as to why. So what i would like to know is why is it that i can change the background color of a widget if i simply create a QWidget object, or a subclass of QPushButton, but not when i create a subclass of QWidget. And how can i therefore change the background color of an object that is a subclass of QWidget? Is it maybe something specific to the version of python or PyQt that i am using? Is it a bug in the library? or some flaw in the way that i am writing my code? I am using python 2.6.4 and PyQt4 Below is an example of the code that leads me to trouble. There are three widgets within the window one below the other. The parent widget is set with background color of green. The top widget is set to red, the middle one, is the subclass of QWidget, which should be blue, but it appears invisible because it takes on the color of the parent window for some reason. and the bottom widget is a subclass of QPushButton and is white. import sys from PyQt4 import QtGui, QtCore ################################################################################ #--------------------------------------------------------- CUSTOM WIDGET CLASS 1 class CustomWidget(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, parent) # some custom properties and functions will follow ################################################################################ #--------------------------------------------------------- CUSTOM WIDGET CLASS 2 class CustomWidget2(QtGui.QPushButton): def __init__(self, parent): QtGui.QPushButton.__init__(self, parent) # some custom properties and functions will follow ################################################################################ #----------------------------------------------------------- PARENT WIDGET CLASS class Parent(QtGui.QWidget): def __init__(self, parent=None): #---------------------------------------------------------- SETUP WINDOW QtGui.QWidget.__init__(self, parent) self.resize(500, 340) self.setStyleSheet("QWidget {background-color: #00FF00}") #-------------------------------------------------- SETUP DEFAULT WIDGET wid1 = QtGui.QWidget(self) wid1.setGeometry(10, 10, 480, 100) wid1.setStyleSheet("QWidget {background-color: #FF0000 }") #------------------------------------------------- SETUP CUSTOM WIDGET 1 wid2 = CustomWidget(self) wid2.setGeometry(10, 120, 480, 100) wid2.setStyleSheet("QWidget {background-color: #0000FF }") for i in dir(wid2): print i #------------------------------------------------- SETUP CUSTOM WIDGET 2 wid3 = CustomWidget2(self) wid3.setGeometry(10, 230, 480, 100) wid3.setStyleSheet("QWidget {background-color: #FFFFFF }") ################################################################################ #-------------------------------------------------------------------------- MAIN app = QtGui.QApplication(sys.argv) win = Parent() win.show() app.exec_()

    Read the article

  • Constructor versus setter injection

    - by Chris
    Hi, I'm currently designing an API where I wish to allow configuration via a variety of methods. One method is via an XML configuration schema and another method is through an API that I wish to play nicely with Spring. My XML schema parsing code was previously hidden and therefore the only concern was for it to work but now I wish to build a public API and I'm quite concerned about best-practice. It seems that many favor javabean type PoJo's with default zero parameter constructors and then setter injection. The problem I am trying to tackle is that some setter methods implementations are dependent on other setter methods being called before them in sequence. I could write anal setters that will tolerate themselves being called in many orders but that will not solve the problem of a user forgetting to set the appropriate setter and therefore the bean being in an incomplete state. The only solution I can think of is to forget about the objects being 'beans' and enforce the required parameters via constructor injection. An example of this is in the default setting of the id of a component based on the id of the parent components. My Interface public interface IMyIdentityInterface { public String getId(); /* A null value should create a unique meaningful default */ public void setId(String id); public IMyIdentityInterface getParent(); public void setParent(IMyIdentityInterface parent); } Base Implementation of interface: public abstract class MyIdentityBaseClass implements IMyIdentityInterface { private String _id; private IMyIdentityInterface _parent; public MyIdentityBaseClass () {} @Override public String getId() { return _id; } /** * If the id is null, then use the id of the parent component * appended with a lower-cased simple name of the current impl * class along with a counter suffix to enforce uniqueness */ @Override public void setId(String id) { if (id == null) { IMyIdentityInterface parent = getParent(); if (parent == null) { // this may be the top level component or it may be that // the user called setId() before setParent(..) } else { _id = Helpers.makeIdFromParent(parent,getClass()); } } else { _id = id; } } @Override public IMyIdentityInterface getParent() { return _parent; } @Override public void setParent(IMyIdentityInterface parent) { _parent = parent; } } Every component in the framework will have a parent except for the top level component. Using the setter type of injection, then the setters will have different behavior based on the order of the calling of the setters. In this case, would you agree, that a constructor taking a reference to the parent is better and dropping the parent setter method from the interface entirely? Is it considered bad practice if I wish to be able to configure these components using an IoC container? Chris

    Read the article

  • wxpython - Nested Notebooks

    - by madtowneast
    I have been trying to make my nested notebooks a little bit more appealing code wise. At the moment, I got this #!/usr/bin/env python import os import sys import datetime import numpy as np from readmonifile import MonitorFile from sortmonifile import sort import wx class NestedPanelOne(wx.Panel): #---------------------------------------------------------------------- # First notebook that creates the tab to select the component number #---------------------------------------------------------------------- def __init__(self, parent, label, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) #Loop creating the tabs according to the component name nestedNotebook = wx.Notebook(self, wx.ID_ANY) for slabel in sorted(data[label].keys()): tab = NestedPanelTwo(nestedNotebook, label, slabel, data) nestedNotebook.AddPage(tab,slabel) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(nestedNotebook, 1, wx.ALL|wx.EXPAND, 5) self.SetSizer(sizer) class NestedPanelTwo(wx.Panel): #------------------------------------------------------------------------------ # Second notebook that creates the tab to select the main monitoring variables #------------------------------------------------------------------------------ def __init__(self, parent, label, slabel, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) sizer = wx.BoxSizer(wx.VERTICAL) nestedNotebook = wx.Notebook(self, wx.ID_ANY) for sslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]].keys()): tab = NestedPanelThree(nestedNotebook, label, slabel, sslabel, data) nestedNotebook.AddPage(tab, sslabel) sizer.Add(nestedNotebook, 1, wx.ALL|wx.EXPAND, 5) self.SetSizer(sizer) class NestedPanelThree(wx.Panel): #------------------------------------------------------------------------------- # Third notebook that creates checkboxes to select the monitoring sub-variables #------------------------------------------------------------------------------- def __init__(self, parent, label, slabel, sslabel, data): wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY) labels=[] chbox =[] chboxdict={} for ssslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]][sslabel].keys()): labels.append(ssslabel) for item in list(set(labels)): cb = wx.CheckBox(self, -1, item) chbox.append(cb) chboxdict[item]=cb gridSizer = wx.GridSizer(np.shape(list(set(labels)))[0],3, 5, 5) gridSizer.AddMany(chbox) self.SetSizer(gridSizer) ######################################################################## class NestedNotebookDemo(wx.Notebook): #--------------------------------------------------------------------------------- # Main notebook creating tabs for the monitored components #--------------------------------------------------------------------------------- def __init__(self, parent, data): wx.Notebook.__init__(self, parent, id=wx.ID_ANY, style= wx.BK_DEFAULT ) for label in sorted(data.keys()): print label tab = NestedPanelOne(self,label, data) self.AddPage(tab, label) ######################################################################## class DemoFrame(wx.Frame): #---------------------------------------------------------------------- # Putting it all together #---------------------------------------------------------------------- def __init__(self,data): wx.Frame.__init__(self, None, wx.ID_ANY, "pDAQ monitoring plotting tool", size=(800,400) ) panel = wx.Panel(self) notebook = NestedNotebookDemo(panel, data) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 5) panel.SetSizer(sizer) self.Layout() #Menu Bar to be added later ''' menubar = wx.MenuBar() file = wx.Menu() file.Append(1, '&Quit', 'Exit Tool') menubar.Append(file, '&File') self.SetMenuBar(menubar) self.Bind(wx.EVT_MENU, self.OnClose, id=1) ''' self.Show() #---------------------------------------------------------------------- if __name__ == "__main__": if len(sys.argv) == 1: raise SystemExit("Please specify a file to process") for f in sys.argv[1:]: data=sort.sorting(f) print data['stringHub'].keys() print data.keys() print data[data.keys()[0]].keys() print 'test' app = wx.PySimpleApp() frame = DemoFrame(data) app.MainLoop() print 'testend' and I would like to reduce this whole mess into something that only has three nested for loops, so something like for label in sorted(data.keys()): self.SubNoteBooks[label] = wx.Notebook(self.Notebook, wx.ID_ANY) self.Notebook.AddPage(self.SubNoteBooks[label], label) for slabel in sorted(data[label].keys()): self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) self.SubNoteBooks[label].AddPage(self.SubNoteBooks[label][slabel], slabel) for sslabel in sorted(data[label][slabel][data[label][slabel].keys()[0]].keys()): self.SubNoteBooks[label][slabel][sslabel] = wx.Notebook(self.Notebook, wx.ID_ANY) self.Notebook.AddPage(self.SubNoteBooks[label][slabel][sslabel], sslabel) I have been trying to fiddle this around but the problem seems to be the line self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) I get the error: Traceback (most recent call last): File "./reducelinenumbers.py", line 162, in <module> frame = DemoFrame(data) File "./reducelinenumbers.py", line 126, in __init__ self.SubNoteBooks[label][slabel] = wx.Notebook(self, wx.ID_ANY) TypeError: 'Notebook' object does not support item assignment I understand why notebook is being type raises a TypeError here. Is there a way around this? Thanks a bunch in advance.

    Read the article

  • transforming flat php array into multidimensional one based on key value?

    - by PopRocks4344
    I have a flat array that I'm trying to make multidimensional. Basically, I want to find the items that have parents and create a subarray for that parent id. Right now (and this is simplified), it looks like this: Array ( [0] => stdClass Object ( [id] => 1 [parent] => 0 [name ] => Parent1 ) [1] => stdClass Object ( [id] => 7 [parent] => 1 [name] => Child1 ) [2] => stdClass Object ( [id] => 9 [parent] => 1 [name] => Child2 ) [3] => stdClass Object ( [id] => 2 [parent] => 0 [name ] => Parent2 ) [4] => stdClass Object ( [id] => 88 [parent] => 2 [name] => Childof2 ) ) I'm trying to make this: Array ( [0] => stdClass Object ( [id] => 1 [parent] => 0 [name ] => Parent1 [children] => stdClass Object ( [1] => stdClass Object ( [id] => 7 [parent] => 1 [name] => Child1 ) [2] => stdClass Object ( [id] => 9 [parent] => 1 [name] => Child2 ) ) ) [1] => stdClass Object ( [id] => 2 [parent] => 0 [name ] => Parent2 [children] => stdClass Object ( [0] => stdClass Object ( [id] => 88 [parent] => 2 [name] => Childof2 ) ) ) )

    Read the article

  • Problems using wondershaper on KVM guest

    - by Daniele Testa
    I am trying to limit bandwidth on one of my KVM guest using Wondershaper. Doing something like this works fine: wondershaper br23 9000 9000 Doing a wget with the setting above gives a download speed of about 1MB/sec like it should. However, it seems this is the highest setting I can use, because setting it to this does not work: wondershaper br23 10000 10000 Doing the same wget with the setting above downloads with full speed, about 70MB/sec in my case. Running a status-check returns the following: qdisc cbq 1: root refcnt 2 rate 10000Kbit (bounded,isolated) prio no-transmit Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 qdisc sfq 10: parent 1:10 limit 127p quantum 1514b divisor 1024 perturb 10sec Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 qdisc sfq 20: parent 1:20 limit 127p quantum 1514b divisor 1024 perturb 10sec Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 qdisc sfq 30: parent 1:30 limit 127p quantum 1514b divisor 1024 perturb 10sec Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 qdisc ingress ffff: parent ffff:fff1 ---------------- Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 class cbq 1: root rate 10000Kbit (bounded,isolated) prio no-transmit Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 class cbq 1:1 parent 1: rate 10000Kbit (bounded,isolated) prio 5 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 class cbq 1:10 parent 1:1 leaf 10: rate 10000Kbit prio 1 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 class cbq 1:20 parent 1:1 leaf 20: rate 9000Kbit prio 2 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 class cbq 1:30 parent 1:1 leaf 30: rate 8000Kbit prio 2 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 borrowed 0 overactions 0 avgidle 12500 undertime 0 What am I doing wrong? Does wondershaper have some kind of upper limit?

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >