001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.backgroundtask;
016    
017    import com.liferay.portal.kernel.util.StringPool;
018    
019    /**
020     * @author Daniel Kocsis
021     * @author Eduardo Garcia
022     */
023    public class BackgroundTaskConstants {
024    
025            public static final String BACKGROUND_TASK_ID = "backgroundTaskId";
026    
027            public static final int ISOLATION_LEVEL_CLASS = 1;
028    
029            public static final int ISOLATION_LEVEL_COMPANY = 2;
030    
031            public static final int ISOLATION_LEVEL_GROUP = 3;
032    
033            public static final int ISOLATION_LEVEL_NOT_ISOLATED = 4;
034    
035            public static final int ISOLATION_LEVEL_TASK_NAME = 5;
036    
037            public static final String LABEL_CANCELLED = "cancelled";
038    
039            public static final String LABEL_FAILED = "failed";
040    
041            public static final String LABEL_IN_PROGRESS = "in-progress";
042    
043            public static final String LABEL_NEW = "new";
044    
045            public static final String LABEL_QUEUED = "queued";
046    
047            public static final String LABEL_SUCCESSFUL = "successful";
048    
049            public static final int STATUS_CANCELLED = 5;
050    
051            public static final int STATUS_FAILED = 2;
052    
053            public static final int STATUS_IN_PROGRESS = 1;
054    
055            public static final int STATUS_NEW = 0;
056    
057            public static final int STATUS_QUEUED = 4;
058    
059            public static final int STATUS_SUCCESSFUL = 3;
060    
061            public static String getStatusCssClass(int status) {
062                    if (status == STATUS_CANCELLED) {
063                            return "label-info";
064                    }
065                    else if (status == STATUS_FAILED) {
066                            return "label-danger";
067                    }
068                    else if (status == STATUS_IN_PROGRESS) {
069                            return "label-warning";
070                    }
071                    else if ((status == BackgroundTaskConstants.STATUS_NEW) ||
072                                     (status == BackgroundTaskConstants.STATUS_QUEUED)) {
073    
074                            return "label-info";
075                    }
076                    else if (status == STATUS_SUCCESSFUL) {
077                            return "label-success";
078                    }
079    
080                    return StringPool.BLANK;
081            }
082    
083            public static String getStatusLabel(int status) {
084                    if (status == STATUS_CANCELLED) {
085                            return LABEL_CANCELLED;
086                    }
087                    else if (status == STATUS_FAILED) {
088                            return LABEL_FAILED;
089                    }
090                    else if (status == STATUS_IN_PROGRESS) {
091                            return LABEL_IN_PROGRESS;
092                    }
093                    else if (status == STATUS_NEW) {
094                            return LABEL_NEW;
095                    }
096                    else if (status == STATUS_QUEUED) {
097                            return LABEL_QUEUED;
098                    }
099                    else if (status == STATUS_SUCCESSFUL) {
100                            return LABEL_SUCCESSFUL;
101                    }
102                    else {
103                            return StringPool.BLANK;
104                    }
105            }
106    
107    }