Ignore:
Timestamp:
11/15/12 11:01:02 (12 years ago)
Author:
vmipsl
Message:

account BD

Location:
ether_statistics/persistence/implementation/com/ether/dao/account
Files:
1 added
3 copied

Legend:

Unmodified
Added
Removed
  • ether_statistics/persistence/implementation/com/ether/dao/account/Account.hbm.xml

    r549 r667  
    44 
    55<hibernate-mapping> 
    6     <class name="com.ether.simulation.Simulation" table="simulation" schema="public"> 
     6    <class name="com.ether.account.Account" table="account" schema="public"> 
    77        <id name="id"> 
    88            <column name="id"/> 
    9  
    10             <generator class="sequence"> 
    11                 <param name="sequence">s_simulation</param> 
    12             </generator> 
    139        </id> 
    1410 
    15         <property name="location"> 
    16             <column name="location"/> 
     11        <property name="name"> 
     12            <column name="name"/> 
    1713        </property> 
    1814 
    19         <property name="xmlnsHeader"> 
    20             <column name="xmlnsheader"/> 
     15        <property name="login"> 
     16            <column name="login"/> 
    2117        </property> 
    2218 
    23         <set name="dimension" table="rel_simulation_dimension"> 
    24             <key> 
    25                 <column name="simulation_id" not-null="true"> 
    26                     <comment>The primary key</comment> 
    27                 </column> 
    28             </key> 
     19        <property name="password"> 
     20            <column name="password"/> 
     21        </property> 
    2922 
    30             <many-to-many entity-name="com.ether.simulation.Dimension"> 
    31                 <column name="dimension_id" not-null="true"/> 
    32             </many-to-many> 
    33         </set> 
    34  
    35         <set name="attribute" table="rel_simulation_attribute"> 
    36             <key> 
    37                 <column name="simulation_id" not-null="true"> 
    38                     <comment>The primary key</comment> 
    39                 </column> 
    40             </key> 
    41  
    42             <many-to-many entity-name="com.ether.simulation.Attribute"> 
    43                 <column name="attribute_id" not-null="true"/> 
    44             </many-to-many> 
    45         </set> 
    46  
    47         <set name="variable" table="rel_simulation_variable"> 
    48             <key> 
    49                 <column name="simulation_id" not-null="true"> 
    50                     <comment>The primary key</comment> 
    51                 </column> 
    52             </key> 
    53  
    54             <many-to-many entity-name="com.ether.simulation.Variable"> 
    55                 <column name="variable_id" not-null="true"/> 
    56             </many-to-many> 
    57         </set> 
    58  
    59         <property name="dates"> 
    60             <column name="dates"/> 
     23        <property name="role" type="com.ether.dao.account.AccountRoleEnum"> 
     24            <column name="role"/> 
    6125        </property> 
    6226 
  • ether_statistics/persistence/implementation/com/ether/dao/account/AccountDAOImpl.java

    r550 r667  
    1 package com.ether.dao.simulation; 
     1package com.ether.dao.account; 
    22 
    33import com.ether.PersistenceException; 
    4 import com.ether.dao.SearchableAbstractHibernateMappingDAO; 
    5 import com.ether.simulation.Simulation; 
    6 import com.ether.simulation.SimulationFilter; 
     4import com.ether.account.Account; 
     5import com.ether.dao.AccountDAO; 
     6import com.ether.dao.DomainAccessObjectImpl; 
    77import org.hibernate.criterion.DetachedCriteria; 
    8 import org.hibernate.criterion.Order; 
    9 import org.hibernate.criterion.Projections; 
    108import org.hibernate.criterion.Restrictions; 
    119import org.jetbrains.annotations.NotNull; 
    1210import org.jetbrains.annotations.Nullable; 
    13 import org.springframework.util.StringUtils; 
    14  
    15 import java.util.ArrayList; 
    16 import java.util.List; 
    1711 
    1812/** 
    1913 * @author vmipsl 
    20  * @date 13 juillet 2012 
     14 * @date 12 nov. 2012 
    2115 */ 
    22 public class SimulationDAOImpl 
    23         extends SearchableAbstractHibernateMappingDAO<Simulation, Integer, SimulationFilter> 
    24         implements SimulationDAO 
     16public class AccountDAOImpl 
     17        extends DomainAccessObjectImpl<Account, Integer> 
     18        implements AccountDAO 
    2519{ 
    26     protected SimulationDAOImpl() 
     20    protected AccountDAOImpl() 
    2721    { 
    28         super( Simulation.class, Integer.class ); 
     22        super( Account.class, Integer.class ); 
    2923    } 
    3024 
    3125    @Nullable 
    32     public Simulation getSimulationByLocation( @NotNull final String location ) 
     26    public Account getAccountByLogin( @NotNull final String login ) 
    3327            throws PersistenceException 
    3428    { 
    35         final DetachedCriteria criteria = DetachedCriteria.forClass( Simulation.class ) 
    36                 .add( Restrictions.eq( "location", location ) ); 
    37         return selectByCriteria( Simulation.class, criteria ); 
    38     } 
    39  
    40     @Nullable 
    41     public List<List<String>> getAllModels() 
    42             throws PersistenceException 
    43     { 
    44         final DetachedCriteria criteriaTitles = createCriteriaForModels( "Title", true ); 
    45         final List<Object[]> listTitles = selectAllByCriteria( Object[].class, criteriaTitles ); 
    46  
    47         final DetachedCriteria criteriaVersions = createCriteriaForModels( "Chimere_version", true ); 
    48         final List<Object[]> listVersions = selectAllByCriteria( Object[].class, criteriaVersions ); 
    49  
    50         final DetachedCriteria criteriaLevels = createCriteriaForModels( "bottom_top", false ); 
    51         final List<Object[]> listLevels = selectAllByCriteria( Object[].class, criteriaLevels ); 
    52  
    53         final List<List<String>> modelsList = new ArrayList<List<String>>(); 
    54         int i = 0; 
    55         for( final Object[] title : listTitles ) 
    56         { 
    57             final String version = (String) listVersions.get( i )[1]; 
    58             final String level = (String) listLevels.get( i )[1]; 
    59             final List<String> values = new ArrayList<String>( 3 ); 
    60             values.add( title[0].toString() ); 
    61             values.add( (String) title[1] ); 
    62             values.add( version ); 
    63             values.add( (String) title[2] ); 
    64             values.add( level ); 
    65             i++; 
    66             modelsList.add( values ); 
    67         } 
    68  
    69         return modelsList; 
    70     } 
    71  
    72     @Nullable 
    73     public String getLocationByModelId( @NotNull final Integer modelId ) 
    74             throws PersistenceException 
    75     { 
    76         final DetachedCriteria criteria = DetachedCriteria.forClass( Simulation.class ) 
    77                 .add( Restrictions.idEq( modelId ) ) 
    78                 .setProjection( Projections.property( "location" ) ); 
    79  
    80         return selectByCriteria( String.class, criteria ); 
    81     } 
    82  
    83     @Override 
    84     protected DetachedCriteria searchCriteria( @NotNull final SimulationFilter filter, final boolean isForCount ) 
    85     { 
    86         final DetachedCriteria criteria = DetachedCriteria.forClass( Simulation.class ); 
    87  
    88         if( StringUtils.hasText( filter.getSearchText() ) ) 
    89             criteria.add( Restrictions.or( escapedLike( "location", filter.getSearchText() ), escapedLike( "xmlnsHeader", filter.getSearchText() ) ) ); 
    90  
    91         if( !isForCount ) 
    92             criteria.addOrder( Order.asc( filter.getSort() ) ); 
    93         return criteria; 
    94     } 
    95  
    96     @NotNull 
    97     private DetachedCriteria createCriteriaForModels( @NotNull final String attributeName, final boolean isAttribute ) 
    98     { 
    99         final DetachedCriteria criteria = DetachedCriteria.forClass( Simulation.class, "simulation" ); 
    100         if( isAttribute ) 
    101             criteria.createCriteria( "attribute", "attribute" ) 
    102                     .add( Restrictions.eq( "attribute.name", attributeName ) ) 
    103                     .setProjection( Projections.projectionList() 
    104                             .add( Projections.property( "simulation.id" ) ) 
    105                             .add( Projections.property( "attribute.value" ) ) 
    106                             .add( Projections.property( "simulation.dates" ) ) 
    107                     ); 
    108         else 
    109             criteria.createCriteria( "dimension", "dimension" ) 
    110                     .add( Restrictions.eq( "dimension.name", attributeName ) ) 
    111                     .setProjection( Projections.projectionList() 
    112                             .add( Projections.property( "simulation.id" ) ) 
    113                             .add( Projections.property( "dimension.length" ) ) 
    114                             .add( Projections.property( "simulation.dates" ) ) 
    115                     ); 
    116  
    117         return criteria.addOrder( Order.asc( "simulation.id" ) ); 
     29        final DetachedCriteria criteria = DetachedCriteria.forClass( Account.class ) 
     30                .add( Restrictions.eq( "login", login ) ); 
     31        return selectByCriteria( Account.class, criteria ); 
    11832    } 
    11933} 
  • ether_statistics/persistence/implementation/com/ether/dao/account/AccountRoleEnum.java

    r423 r667  
    1 package com.ether.dao.user; 
     1package com.ether.dao.account; 
    22 
    33import com.ether.EnumUserType; 
    4 import com.ether.user.UserRole; 
     4import com.ether.account.AccountRole; 
    55 
    66/** 
    7  * User: vmipsl 
    8  * Date: 25 nov. 2011 
     7 * @author vmipsl 
     8 * @date 12 nov. 2012 
    99 */ 
    10 public class UserRoleEnum 
    11         extends EnumUserType<UserRole> 
     10public class AccountRoleEnum 
     11        extends EnumUserType<AccountRole> 
    1212{ 
    13     public UserRoleEnum() 
     13    public AccountRoleEnum() 
    1414    { 
    15         super( UserRole.class ); 
     15        super( AccountRole.class ); 
    1616    } 
    1717} 
Note: See TracChangeset for help on using the changeset viewer.