mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
- Some renaming in Chile
- EntityLog
This commit is contained in:
parent
4a21550ad8
commit
5609fd3d3e
@ -25,7 +25,7 @@ create table SYS_CONFIG (
|
||||
UPDATE_TS datetime,
|
||||
UPDATED_BY varchar(20),
|
||||
NAME varchar(255),
|
||||
VALUE varchar(500),
|
||||
VALUE varchar(1500),
|
||||
primary key (ID)
|
||||
)^
|
||||
|
||||
|
@ -25,7 +25,7 @@ create table SYS_CONFIG (
|
||||
UPDATE_TS timestamp,
|
||||
UPDATED_BY varchar(20),
|
||||
NAME varchar(255),
|
||||
VALUE varchar(500),
|
||||
VALUE varchar(1500),
|
||||
primary key (ID)
|
||||
);
|
||||
|
||||
@ -189,6 +189,51 @@ alter table SEC_USER_SETTING add constraint SEC_USER_SETTING_UNIQ unique (USER_I
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
create table SEC_LOGGED_ENTITY (
|
||||
ID varchar(36),
|
||||
CREATE_TS timestamp,
|
||||
CREATED_BY varchar(20),
|
||||
NAME varchar(50),
|
||||
primary key (ID)
|
||||
);
|
||||
|
||||
alter table SEC_LOGGED_ENTITY add constraint SEC_LOGGED_ENTITY_UNIQ_NAME unique (NAME);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
create table SEC_LOGGED_ATTR (
|
||||
ID varchar(36),
|
||||
CREATE_TS timestamp,
|
||||
CREATED_BY varchar(20),
|
||||
ENTITY_ID varchar(36),
|
||||
NAME varchar(50),
|
||||
primary key (ID)
|
||||
);
|
||||
|
||||
alter table SEC_LOGGED_ATTR add constraint FK_SEC_LOGGED_ATTR_ENTITY foreign key (ENTITY_ID) references SEC_LOGGED_ENTITY(ID);
|
||||
|
||||
alter table SEC_LOGGED_ATTR add constraint SEC_LOGGED_ATTR_UNIQ_NAME unique (ENTITY_ID, NAME);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
create table SEC_ENTITY_LOG (
|
||||
ID varchar(36),
|
||||
CREATE_TS timestamp,
|
||||
CREATED_BY varchar(20),
|
||||
EVENT_TS timestamp,
|
||||
USER_ID varchar(36),
|
||||
TYPE char(1),
|
||||
ENTITY varchar(50),
|
||||
ATTR varchar(50),
|
||||
VALUE varchar(500),
|
||||
OLD_VALUE varchar(500),
|
||||
primary key (ID)
|
||||
);
|
||||
|
||||
alter table SEC_ENTITY_LOG add constraint FK_SEC_ENTITY_LOG_USER foreign key (USER_ID) references SEC_USER(ID);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
insert into SEC_GROUP (ID, CREATE_TS, VERSION, NAME, PARENT_ID)
|
||||
values ('0fa2b1a5-1d68-4d69-9fbd-dff348347f93', current_timestamp, 0, 'Company', null);
|
||||
|
||||
|
@ -1,12 +1,22 @@
|
||||
<?xml version='1.0' encoding='UTF-8' ?>
|
||||
<server>
|
||||
<mbean code="com.haulmont.cuba.core.app.CubaDeployer"
|
||||
name="haulmont.cuba:service=CubaDeployer">
|
||||
<depends>jboss:service=TransactionManager</depends>
|
||||
</mbean>
|
||||
|
||||
<mbean code="com.haulmont.cuba.core.app.ResourceRepository"
|
||||
name="haulmont.cuba:service=ResourceRepository">
|
||||
<depends>jboss:service=TransactionManager</depends>
|
||||
<depends>haulmont.cuba:service=CubaDeployer</depends>
|
||||
</mbean>
|
||||
|
||||
<mbean code="com.haulmont.cuba.core.app.ConfigStorage"
|
||||
name="haulmont.cuba:service=ConfigStorage">
|
||||
<depends>jboss:service=TransactionManager</depends>
|
||||
<depends>haulmont.cuba:service=CubaDeployer</depends>
|
||||
</mbean>
|
||||
|
||||
<mbean code="com.haulmont.cuba.security.app.EntityLog"
|
||||
name="haulmont.cuba:service=EntityLog">
|
||||
<depends>haulmont.cuba:service=CubaDeployer</depends>
|
||||
</mbean>
|
||||
</server>
|
||||
|
@ -16,6 +16,9 @@
|
||||
<class>com.haulmont.cuba.security.entity.Permission</class>
|
||||
<class>com.haulmont.cuba.security.entity.Constraint</class>
|
||||
<class>com.haulmont.cuba.security.entity.UserSetting</class>
|
||||
<class>com.haulmont.cuba.security.entity.LoggedEntity</class>
|
||||
<class>com.haulmont.cuba.security.entity.LoggedAttribute</class>
|
||||
<class>com.haulmont.cuba.security.entity.EntityLogItem</class>
|
||||
|
||||
<properties>
|
||||
<property name="openjpa.ManagedRuntime" value="org.apache.openjpa.ee.JNDIManagedRuntime"/>
|
||||
|
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 17:43:12
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.core.app;
|
||||
|
||||
public class CubaDeployer implements CubaDeployerMBean
|
||||
{
|
||||
public void create() {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 17:42:45
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.core.app;
|
||||
|
||||
public interface CubaDeployerMBean
|
||||
{
|
||||
void create();
|
||||
|
||||
void start();
|
||||
}
|
@ -17,9 +17,6 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.openjpa.persistence.Persistent;
|
||||
|
||||
@Entity(name = "core$Config")
|
||||
@Table(name = "SYS_CONFIG")
|
||||
@ -40,7 +37,7 @@ public class Config extends BaseUuidEntity implements Versioned, Updatable
|
||||
@Column(name = "NAME")
|
||||
private String name;
|
||||
|
||||
@Column(name = "VALUE", length = 500)
|
||||
@Column(name = "VALUE", length = 1500)
|
||||
private String value;
|
||||
|
||||
public Integer getVersion() {
|
||||
|
@ -12,7 +12,6 @@ package com.haulmont.cuba.core.entity;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EntityListeners;
|
||||
|
||||
@Entity(name = "core$Server")
|
||||
@Table(name = "SYS_SERVER")
|
||||
|
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 16:10:25
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.security.app;
|
||||
|
||||
import com.haulmont.cuba.core.*;
|
||||
import com.haulmont.cuba.security.entity.LoggedEntity;
|
||||
import com.haulmont.cuba.security.entity.LoggedAttribute;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
public class EntityLog implements EntityLogMBean
|
||||
{
|
||||
private Map<String, Set<String>> entities;
|
||||
|
||||
private ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
public void create() {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
}
|
||||
|
||||
public EntityLog getImplementation() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void invalidateCache() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
entities = null;
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Set<String> getLoggedAttributes(String entity) {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
if (entities == null) {
|
||||
// upgrade lock
|
||||
lock.readLock().unlock();
|
||||
lock.writeLock().lock();
|
||||
|
||||
entities = new HashMap<String, Set<String>>();
|
||||
loadEntities();
|
||||
|
||||
// downgrade lock
|
||||
lock.writeLock().unlock();
|
||||
lock.readLock().lock();
|
||||
}
|
||||
Set<String> attributes = entities.get(entity);
|
||||
return attributes == null ? null : Collections.unmodifiableSet(attributes);
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadEntities() {
|
||||
Transaction tx = Locator.getTransaction();
|
||||
try {
|
||||
EntityManager em = PersistenceProvider.getEntityManager();
|
||||
Query q = em.createQuery("select e from core$LoggedEntity e join fetch e.attributes");
|
||||
List<LoggedEntity> list = q.getResultList();
|
||||
for (LoggedEntity loggedEntity : list) {
|
||||
Set<String> attributes = new HashSet<String>();
|
||||
for (LoggedAttribute loggedAttribute : loggedEntity.getAttributes()) {
|
||||
attributes.add(loggedAttribute.getName());
|
||||
}
|
||||
entities.put(loggedEntity.getEntity(), attributes);
|
||||
}
|
||||
tx.commit();
|
||||
} finally {
|
||||
tx.end();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 16:09:14
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.security.app;
|
||||
|
||||
public interface EntityLogMBean
|
||||
{
|
||||
String OBJECT_NAME = "haulmont.cuba:service=EntityLog";
|
||||
|
||||
void create();
|
||||
|
||||
void start();
|
||||
|
||||
EntityLog getImplementation();
|
||||
|
||||
void invalidateCache();
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 17:12:25
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.security.entity;
|
||||
|
||||
import com.haulmont.cuba.core.entity.BaseUuidEntity;
|
||||
import com.haulmont.chile.core.datatypes.impl.EnumClass;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity(name = "sec$EntityLog")
|
||||
@Table(name = "SEC_ENTITY_LOG")
|
||||
public class EntityLogItem extends BaseUuidEntity
|
||||
{
|
||||
private static final long serialVersionUID = 5859030306889056606L;
|
||||
|
||||
public enum Type implements EnumClass<String>
|
||||
{
|
||||
CREATE("C"),
|
||||
MODIFY("M"),
|
||||
DELETE("D");
|
||||
|
||||
private String id;
|
||||
|
||||
private Type(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Type fromId(String value) {
|
||||
if ("C".equals(value))
|
||||
return CREATE;
|
||||
else if ("M".equals(value))
|
||||
return MODIFY;
|
||||
else if ("D".equals(value))
|
||||
return DELETE;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = "EVENT_TS")
|
||||
private Date eventTs;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "USER_ID")
|
||||
private User user;
|
||||
|
||||
@Column(name = "TYPE", length = 1)
|
||||
private String type;
|
||||
|
||||
@Column(name = "ENTITY", length = 50)
|
||||
private String entity;
|
||||
|
||||
@Column(name = "ATTR", length = 50)
|
||||
private String attribute;
|
||||
|
||||
@Column(name = "VALUE", length = 500)
|
||||
private String value;
|
||||
|
||||
@Column(name = "OLD_VALUE", length = 500)
|
||||
private String oldValue;
|
||||
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
public String getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(String entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public Date getEventTs() {
|
||||
return eventTs;
|
||||
}
|
||||
|
||||
public void setEventTs(Date eventTs) {
|
||||
this.eventTs = eventTs;
|
||||
}
|
||||
|
||||
public String getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
public void setOldValue(String oldValue) {
|
||||
this.oldValue = oldValue;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 16:34:10
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.security.entity;
|
||||
|
||||
import com.haulmont.cuba.core.entity.BaseUuidEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity(name = "sec$LoggedAttribute")
|
||||
@Table(name = "SEC_LOGGED_ATTR")
|
||||
public class LoggedAttribute extends BaseUuidEntity
|
||||
{
|
||||
private static final long serialVersionUID = -615000337312303671L;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "ENTITY_ID")
|
||||
private LoggedEntity entity;
|
||||
|
||||
@Column(name = "NAME")
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LoggedEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(LoggedEntity entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
|
||||
* Author: Konstantin Krivopustov
|
||||
* Created: 17.03.2009 16:23:18
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
package com.haulmont.cuba.security.entity;
|
||||
|
||||
import com.haulmont.cuba.core.entity.BaseUuidEntity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity(name = "sec$LoggedEntity")
|
||||
@Table(name = "SEC_LOGGED_ENTITY")
|
||||
public class LoggedEntity extends BaseUuidEntity
|
||||
{
|
||||
private static final long serialVersionUID = 2189206984294705835L;
|
||||
|
||||
@Column(name = "NAME")
|
||||
private String entity;
|
||||
|
||||
@OneToMany(mappedBy = "entity")
|
||||
private Set<LoggedAttribute> attributes;
|
||||
|
||||
public String getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public void setEntity(String entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public Set<LoggedAttribute> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(Set<LoggedAttribute> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
}
|
@ -51,11 +51,11 @@ public class Permission extends StandardEntity
|
||||
}
|
||||
|
||||
public PermissionType getType() {
|
||||
return type == null ? null : PermissionType.valueOf(type);
|
||||
return type == null ? null : PermissionType.fromId(type);
|
||||
}
|
||||
|
||||
public void setType(PermissionType type) {
|
||||
this.type = type == null ? null : type.getValue();
|
||||
this.type = type == null ? null : type.getId();
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
|
@ -31,14 +31,14 @@ public enum PermissionType implements EnumClass<Integer>
|
||||
}
|
||||
|
||||
/** Returns corresponding database value */
|
||||
public Integer getValue() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Constructs type from corresponding database value */
|
||||
public static PermissionType valueOf(Integer id) {
|
||||
public static PermissionType fromId(Integer id) {
|
||||
for (PermissionType type : PermissionType.values()) {
|
||||
if (ObjectUtils.equals(type.getValue(), id)) {
|
||||
if (ObjectUtils.equals(type.getId(), id)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
*/
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.chile.core.datatypes.Enumiration;
|
||||
import com.haulmont.chile.core.datatypes.Enumeration;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.haulmont.cuba.gui.components.CaptionMode;
|
||||
@ -62,7 +62,7 @@ public abstract class AbstractOptionsField<T extends com.itmill.toolkit.ui.Abstr
|
||||
setRequired(metaProperty.isMandatory());
|
||||
|
||||
if (metaProperty.getRange().isEnum()) {
|
||||
final Enumiration enumiration = metaProperty.getRange().asEnumiration();
|
||||
final Enumeration enumiration = metaProperty.getRange().asEnumiration();
|
||||
final Class<Enum> javaClass = enumiration.getJavaClass();
|
||||
|
||||
optionsList = Arrays.asList(javaClass.getEnumConstants());
|
||||
|
@ -9,22 +9,10 @@
|
||||
*/
|
||||
package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.haulmont.cuba.gui.data.CollectionDatasource;
|
||||
import com.haulmont.cuba.gui.data.Datasource;
|
||||
import com.haulmont.cuba.web.gui.data.CollectionDatasourceWrapper;
|
||||
import com.haulmont.cuba.web.gui.data.ItemWrapper;
|
||||
import com.haulmont.cuba.web.gui.data.EnumerationContainer;
|
||||
import com.haulmont.cuba.core.entity.Entity;
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.chile.core.datatypes.Enumiration;
|
||||
import com.itmill.toolkit.ui.Select;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
import com.itmill.toolkit.ui.AbstractSelect;
|
||||
import com.itmill.toolkit.ui.OptionGroup;
|
||||
import com.itmill.toolkit.data.Property;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import com.itmill.toolkit.ui.Select;
|
||||
|
||||
public class LookupField
|
||||
extends
|
||||
|
Loading…
Reference in New Issue
Block a user