- Timestamp:
- 11/15/12 11:01:02 (12 years ago)
- 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 4 4 5 5 <hibernate-mapping> 6 <class name="com.ether. simulation.Simulation" table="simulation" schema="public">6 <class name="com.ether.account.Account" table="account" schema="public"> 7 7 <id name="id"> 8 8 <column name="id"/> 9 10 <generator class="sequence">11 <param name="sequence">s_simulation</param>12 </generator>13 9 </id> 14 10 15 <property name=" location">16 <column name=" location"/>11 <property name="name"> 12 <column name="name"/> 17 13 </property> 18 14 19 <property name=" xmlnsHeader">20 <column name=" xmlnsheader"/>15 <property name="login"> 16 <column name="login"/> 21 17 </property> 22 18 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> 29 22 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"/> 61 25 </property> 62 26 -
ether_statistics/persistence/implementation/com/ether/dao/account/AccountDAOImpl.java
r550 r667 1 package com.ether.dao. simulation;1 package com.ether.dao.account; 2 2 3 3 import com.ether.PersistenceException; 4 import com.ether. dao.SearchableAbstractHibernateMappingDAO;5 import com.ether. simulation.Simulation;6 import com.ether. simulation.SimulationFilter;4 import com.ether.account.Account; 5 import com.ether.dao.AccountDAO; 6 import com.ether.dao.DomainAccessObjectImpl; 7 7 import org.hibernate.criterion.DetachedCriteria; 8 import org.hibernate.criterion.Order;9 import org.hibernate.criterion.Projections;10 8 import org.hibernate.criterion.Restrictions; 11 9 import org.jetbrains.annotations.NotNull; 12 10 import org.jetbrains.annotations.Nullable; 13 import org.springframework.util.StringUtils;14 15 import java.util.ArrayList;16 import java.util.List;17 11 18 12 /** 19 13 * @author vmipsl 20 * @date 1 3 juillet201214 * @date 12 nov. 2012 21 15 */ 22 public class SimulationDAOImpl23 extends SearchableAbstractHibernateMappingDAO<Simulation, Integer, SimulationFilter>24 implements SimulationDAO16 public class AccountDAOImpl 17 extends DomainAccessObjectImpl<Account, Integer> 18 implements AccountDAO 25 19 { 26 protected SimulationDAOImpl()20 protected AccountDAOImpl() 27 21 { 28 super( Simulation.class, Integer.class );22 super( Account.class, Integer.class ); 29 23 } 30 24 31 25 @Nullable 32 public Simulation getSimulationByLocation( @NotNull final String location )26 public Account getAccountByLogin( @NotNull final String login ) 33 27 throws PersistenceException 34 28 { 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 ); 118 32 } 119 33 } -
ether_statistics/persistence/implementation/com/ether/dao/account/AccountRoleEnum.java
r423 r667 1 package com.ether.dao. user;1 package com.ether.dao.account; 2 2 3 3 import com.ether.EnumUserType; 4 import com.ether. user.UserRole;4 import com.ether.account.AccountRole; 5 5 6 6 /** 7 * User:vmipsl8 * Date: 25 nov. 20117 * @author vmipsl 8 * @date 12 nov. 2012 9 9 */ 10 public class UserRoleEnum11 extends EnumUserType< UserRole>10 public class AccountRoleEnum 11 extends EnumUserType<AccountRole> 12 12 { 13 public UserRoleEnum()13 public AccountRoleEnum() 14 14 { 15 super( UserRole.class );15 super( AccountRole.class ); 16 16 } 17 17 }
Note: See TracChangeset
for help on using the changeset viewer.